diff options
| author | Charlie Sharpsteen | 2011-08-25 16:44:43 -0700 |
|---|---|---|
| committer | Charlie Sharpsteen | 2011-08-26 09:44:57 -0700 |
| commit | f78c59fcb3bef92e145ac6c87b2dcdf3be439d70 (patch) | |
| tree | e401a16d3367cb94276348434798780af2a0e614 | |
| parent | 294ca58661a87f0d88c7aedd566a898f80876cc9 (diff) | |
| download | homebrew-f78c59fcb3bef92e145ac6c87b2dcdf3be439d70.tar.bz2 | |
brew-pull: Allow pull request numbers as arguments
If an integer is passed to `brew-pull`, such as `brew pull 6600`, it will be
interpreted as a pull request number. This has the same effect as the more
verbose command line:
brew pull https://github.com/mxcl/homebrew/pull/6600
| -rwxr-xr-x | Library/Contributions/examples/brew-pull.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/Library/Contributions/examples/brew-pull.rb b/Library/Contributions/examples/brew-pull.rb index 34fb0e4d3..61467ef66 100755 --- a/Library/Contributions/examples/brew-pull.rb +++ b/Library/Contributions/examples/brew-pull.rb @@ -9,20 +9,24 @@ if ARGV.include? '--install' end if ARGV.empty? - onoe 'This command requires at least one URL argument' + onoe 'This command requires at least one argument containing a URL or pull request number' end HOMEBREW_REPOSITORY.cd do ARGV.each do|arg| - # This regex should work, if it's too precise, feel free to fix it. - urlmatch = arg.match 'https:\/\/github.com\/\w+\/homebrew\/(pull\/(\d+)|commit\/\w{4,40})' - if !urlmatch - ohai 'Ignoring URL:', "Not a GitHub pull request or commit: #{arg}" - next - end + if arg.to_i > 0 + url = 'https://github.com/mxcl/homebrew/pull/' + arg + '.patch' + else + # This regex should work, if it's too precise, feel free to fix it. + urlmatch = arg.match 'https:\/\/github.com\/\w+\/homebrew\/(pull\/(\d+)|commit\/\w{4,40})' + if !urlmatch + ohai 'Ignoring URL:', "Not a GitHub pull request or commit: #{arg}" + next + end - # GitHub provides commits'/pull-requests' raw patches using this URL. - url = urlmatch[0] + '.patch' + # GitHub provides commits'/pull-requests' raw patches using this URL. + url = urlmatch[0] + '.patch' + end # The cache directory seems like a good place to put patches. patchpath = (HOMEBREW_CACHE+File.basename(url)) @@ -35,7 +39,7 @@ HOMEBREW_REPOSITORY.cd do ohai 'Applying patch' safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath - issue = urlmatch[2] + issue = arg.to_i > 0 ? arg.to_i : urlmatch[2] if issue ohai "Patch closes issue ##{issue}" message = `git log HEAD^.. --format=%B` |
