From 877e911cbab69b2a64b56e187beb3783f960b473 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 2 Jan 2011 11:38:22 +0000 Subject: [PATCH] brew-pull: Handle multipatch pull requests better. --- Library/Contributions/examples/brew-pull.rb | 26 ++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Library/Contributions/examples/brew-pull.rb b/Library/Contributions/examples/brew-pull.rb index 70b37b9364..544645486d 100755 --- a/Library/Contributions/examples/brew-pull.rb +++ b/Library/Contributions/examples/brew-pull.rb @@ -9,8 +9,7 @@ if ARGV.include? '--install' end if ARGV.empty? - puts 'This command requires at least one URL argument' - exit 1 + onoe 'This command requires at least one URL argument' end HOMEBREW_REPOSITORY.cd do @@ -29,6 +28,9 @@ HOMEBREW_REPOSITORY.cd do patchpath = (HOMEBREW_CACHE+File.basename(url)) curl url, '-o', patchpath + # Store current revision + revision = `git log -n1 --format=%H`.strip() + # Makes sense to squash whitespace errors, we don't want them. ohai 'Applying patch' safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath @@ -36,7 +38,7 @@ HOMEBREW_REPOSITORY.cd do issue = urlmatch[2] if issue ohai "Patch closes issue ##{issue}" - message = `git log HEAD^..HEAD --format=%B` + message = `git log #{revision}.. --format=%B` # If this is a pull request, append a close message. if !message.include? 'Closes #' @@ -48,16 +50,18 @@ HOMEBREW_REPOSITORY.cd do end ohai 'Patch changed:' - safe_system 'git', 'diff', 'HEAD^..HEAD', '--stat' + safe_system 'git', 'diff', "#{revision}..", '--stat' if install - status, filename = `git diff HEAD^..HEAD --name-status`.split() - # Don't try and do anything to removed files. - if (status == 'A' or status == 'M') and filename.include? '/Formula/' - formula = File.basename(filename, '.rb') - ohai "Installing #{formula}" - # Not sure if this is the best way to install? - safe_system 'brew', 'install', '--force', formula + `git diff #{revision}.. --name-status`.each_line do |line| + status, filename = line.split() + # Don't try and do anything to removed files. + if (status == 'A' or status == 'M') and filename.include? '/Formula/' + formula = File.basename(filename, '.rb') + ohai "Installing #{formula}" + # Not sure if this is the best way to install? + safe_system 'brew', 'install', '--force', formula + end end end end