Improve brew pull to close issues.

This commit is contained in:
Mike McQuaid 2010-12-30 15:24:54 +00:00
parent d6455e0094
commit dc3623f5a6

View File

@ -16,7 +16,8 @@ end
HOMEBREW_REPOSITORY.cd do
ARGV.each do|arg|
# This regex should work, if it's too precise, feel free to fix it.
if !arg.match 'https:\/\/github.com\/\w+\/homebrew\/(pull\/\d+|commit\/\w{4,40})'
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
@ -32,6 +33,20 @@ HOMEBREW_REPOSITORY.cd do
ohai 'Applying patch'
safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath
issue = urlmatch[2]
if issue
ohai "Patch closes issue ##{issue}"
message = `git log HEAD^..HEAD --format=%B`
# If this is a pull request, append a close message.
if !message.include? 'Closes #'
issueline = "Closes ##{issue}."
signed = 'Signed-off-by:'
message = message.gsub signed, issueline + "\n\n" + signed
safe_system 'git', 'commit', '--amend', '-q', '-m', message
end
end
ohai 'Patch changed:'
safe_system 'git', 'diff', 'HEAD^..HEAD', '--stat'