brew-pull: Handle multipatch pull requests better.
This commit is contained in:
parent
4cf099ecdf
commit
877e911cba
@ -9,8 +9,7 @@ if ARGV.include? '--install'
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ARGV.empty?
|
if ARGV.empty?
|
||||||
puts 'This command requires at least one URL argument'
|
onoe 'This command requires at least one URL argument'
|
||||||
exit 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
HOMEBREW_REPOSITORY.cd do
|
HOMEBREW_REPOSITORY.cd do
|
||||||
@ -29,6 +28,9 @@ HOMEBREW_REPOSITORY.cd do
|
|||||||
patchpath = (HOMEBREW_CACHE+File.basename(url))
|
patchpath = (HOMEBREW_CACHE+File.basename(url))
|
||||||
curl url, '-o', patchpath
|
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.
|
# Makes sense to squash whitespace errors, we don't want them.
|
||||||
ohai 'Applying patch'
|
ohai 'Applying patch'
|
||||||
safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath
|
safe_system 'git', 'am', '--signoff', '--whitespace=fix', patchpath
|
||||||
@ -36,7 +38,7 @@ HOMEBREW_REPOSITORY.cd do
|
|||||||
issue = urlmatch[2]
|
issue = urlmatch[2]
|
||||||
if issue
|
if issue
|
||||||
ohai "Patch closes issue ##{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 this is a pull request, append a close message.
|
||||||
if !message.include? 'Closes #'
|
if !message.include? 'Closes #'
|
||||||
@ -48,16 +50,18 @@ HOMEBREW_REPOSITORY.cd do
|
|||||||
end
|
end
|
||||||
|
|
||||||
ohai 'Patch changed:'
|
ohai 'Patch changed:'
|
||||||
safe_system 'git', 'diff', 'HEAD^..HEAD', '--stat'
|
safe_system 'git', 'diff', "#{revision}..", '--stat'
|
||||||
|
|
||||||
if install
|
if install
|
||||||
status, filename = `git diff HEAD^..HEAD --name-status`.split()
|
`git diff #{revision}.. --name-status`.each_line do |line|
|
||||||
# Don't try and do anything to removed files.
|
status, filename = line.split()
|
||||||
if (status == 'A' or status == 'M') and filename.include? '/Formula/'
|
# Don't try and do anything to removed files.
|
||||||
formula = File.basename(filename, '.rb')
|
if (status == 'A' or status == 'M') and filename.include? '/Formula/'
|
||||||
ohai "Installing #{formula}"
|
formula = File.basename(filename, '.rb')
|
||||||
# Not sure if this is the best way to install?
|
ohai "Installing #{formula}"
|
||||||
safe_system 'brew', 'install', '--force', formula
|
# Not sure if this is the best way to install?
|
||||||
|
safe_system 'brew', 'install', '--force', formula
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user