This repository has been archived by the owner. It is now read-only.

bump-formula-pr: add new command. #49848

Merged
merged 1 commit into from Mar 27, 2016

Conversation

Projects
None yet
5 participants
@MikeMcQuaid
Copy link
Member

MikeMcQuaid commented Mar 7, 2016

Add a new developer command (i.e. requires HOMEBREW_DEVELOPER set in your environment) to bump the version of a formula and create a new pull request with the new version.

CC @mdiep @mislav @xu-cheng

safe_system "hub", "fork", "--no-remote"
quiet_system "hub", "fork"
/fatal: remote (.+) already exists./ =~ Utils.popen_read("hub fork 2>&1")
remote = $1

This comment has been minimized.

@xu-cheng

xu-cheng Mar 8, 2016

Contributor
remote = Utils.popen_read("hub", "fork")[/fatal: remote (.+) already exists./, 1]

This comment has been minimized.

@MikeMcQuaid
@@ -0,0 +1,73 @@
require "formula"

This comment has been minimized.

@xu-cheng

xu-cheng Mar 8, 2016

Contributor

Could you add comment like brew test-bot or brew pull to explain the argument list?

This comment has been minimized.

@MikeMcQuaid
formula_arg = ARGV.named.first
odie "No formula specified!" unless formula_arg
formula = Formula[ARGV.named.first]
odie "No #{formula} formula found!" unless formula

This comment has been minimized.

@xu-cheng

xu-cheng Mar 8, 2016

Contributor

You could use ARGV.formulae.first directly.

This comment has been minimized.

@MikeMcQuaid

MikeMcQuaid Mar 8, 2016

Member

I've got a feeling and tried that and it didn't work for this case but I'll try it again.

This comment has been minimized.

@apjanke

apjanke Mar 8, 2016

Contributor

Shouldn't this be odie "No #{formula_arg} formula found!" unless formula or odie "No #{ARGV.named.first} formula found!" unless formula instead, since formula will be nil in this case, and formula_arg will have the name string?

@xu-cheng

This comment has been minimized.

Copy link
Contributor

xu-cheng commented Mar 8, 2016

What happens if my origin remote is pointed to my own fork and the upstream is pointed to the Homebrew? Sorry, but this is my personal setup.

resource_specs = formula_spec.specs
old_tag = resource_specs[:tag]
old_revision = resource_specs[:revision]
s.gsub!(old_tag, new_tag)

This comment has been minimized.

@xu-cheng

xu-cheng Mar 8, 2016

Contributor

Since the tag is usually version string. This replacement may happen in the wrong places, e.g resources.

This comment has been minimized.

@MikeMcQuaid

MikeMcQuaid Mar 8, 2016

Member

Suggestions for a better replacement?

This comment has been minimized.

@xu-cheng

xu-cheng Mar 8, 2016

Contributor
s.gsub!("\"#{old_tag}\"", "\"#{new_tag}\"")
@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Mar 8, 2016

What happens if my origin remote is pointed to my own fork and the upstream is pointed to the Homebrew? Sorry, but this is my personal setup.

I guess you can play around with hub fork locally and see how it handles that case. The tricky thing is there's not an easy way to get your GitHub username so I'd be in favour of just making this work for the easy-path, even if it requires e.g. a duplicate remote.

@ilovezfs

This comment has been minimized.

Copy link
Contributor

ilovezfs commented Mar 9, 2016

@MikeMcQuaid Actually, getting the username should be straightforward since it's required for hub:

Josephs-MacBook-Pro:homebrew joe$ grep user ~/.config/hub 
- user: ilovezfs

ilovezfs added a commit to ilovezfs/legacy-homebrew that referenced this pull request Mar 9, 2016

bump-formula-pr: add new command.
Add a new developer command (i.e. requires `HOMEBREW_DEVELOPER` set in
your environment) to bump the version of a formula and create a new pull
request with the new version.

Closes Homebrew#49848.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>

formula.path.parent.cd do
branch = "#{formula.name}-#{new_formula_version}"
safe_system "git", "checkout", "-b", branch, "master"

This comment has been minimized.

@ilovezfs

ilovezfs Mar 9, 2016

Contributor

I think you may want origin/master (or upstream/master if you go with @xu-cheng's naming convention) not master to avoid what just happened to me (as a result of having done brew pull 49848 first) :
![alt text](http://i.imgur.com/jDdvaQQ.png oops)

@ilovezfs

This comment has been minimized.

Copy link
Contributor

ilovezfs commented Mar 9, 2016

bump-formula-pr may need some clean-up code when it fails that deletes the branch, reverts the changes, and puts you back on master (or whatever branch you were on originally), so that it's re-runnable. Otherwise, failures have to be manually unwound with git boilerplate before re-running the command.

When the command succeeds, it probably should put you back on your original branch as well.

Also, I think it would be nice if the command would guess the url based on a basic version string replacement if a full URL isn't provided, and also automatically compute the checksum when the download is successful (and possibly also that the archive can be unpacked just to verify it's sane).

As noted here #49918 (comment), the command needs to delete any revision line as well.

@ilovezfs

This comment has been minimized.

Copy link
Contributor

ilovezfs commented Mar 15, 2016

@MikeMcQuaid Having second thoughts about this one?

@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Mar 15, 2016

@ilovezfs Nope, just been busy!

@ilovezfs

This comment has been minimized.

Copy link
Contributor

ilovezfs commented Mar 15, 2016

@MikeMcQuaid Ah, ok! I'd suggest at least integrating the master -> origin/master change so that this can be used via brew pull without replicating my blunder above.

@MikeMcQuaid

This comment has been minimized.

Copy link
Member

MikeMcQuaid commented Mar 17, 2016

Updated (on ✈️ so not tested) and then will ship this soon if it works and there's no objections.

bump-formula-pr: add new command.
Add a new developer command (i.e. requires `HOMEBREW_DEVELOPER` set in
your environment) to bump the version of a formula and create a new pull
request with the new version.

Closes #49848.

@MikeMcQuaid MikeMcQuaid merged commit f106809 into Homebrew:master Mar 27, 2016

1 check was pending

continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@MikeMcQuaid MikeMcQuaid deleted the MikeMcQuaid:bump-formula-pr branch Mar 27, 2016

xu-cheng added a commit to Homebrew/brew that referenced this pull request Mar 28, 2016

bump-formula-pr: add new command.
Add a new developer command (i.e. requires `HOMEBREW_DEVELOPER` set in
your environment) to bump the version of a formula and create a new pull
request with the new version.

Closes Homebrew/legacy-homebrew#49848.
@zbeekman

This comment has been minimized.

Copy link
Member

zbeekman commented Apr 1, 2016

Is the usage documented somewhere? (For bump-formula-pr... )

@zbeekman

This comment has been minimized.

Copy link
Member

zbeekman commented Apr 1, 2016

just saw the comments in the file diff... ignore my previous post

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.