aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2012-11-10 09:05:31 +0000
committerMike McQuaid2012-11-10 09:05:31 +0000
commit25442f20ec639375849f8be65000c367dbc6c5b8 (patch)
tree1f061e9841ba8837f8ecd01f10e70049360cab54 /Library
parentd01adbc987b5b35c2724b8daf52fc1f79e1b8e12 (diff)
downloadbrew-25442f20ec639375849f8be65000c367dbc6c5b8.tar.bz2
brew-test-bot: Change directory only for Git commands.
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/cmds/brew-test-bot.rb27
1 files changed, 19 insertions, 8 deletions
diff --git a/Library/Contributions/cmds/brew-test-bot.rb b/Library/Contributions/cmds/brew-test-bot.rb
index 64c7acba3..e354a3153 100755
--- a/Library/Contributions/cmds/brew-test-bot.rb
+++ b/Library/Contributions/cmds/brew-test-bot.rb
@@ -70,7 +70,14 @@ class Step
def self.run test, command, output_on_success = false
step = new test, command
step.puts_command
- `#{step.command} &>#{step.log_file_path}`
+
+ command = "#{step.command} &>#{step.log_file_path}"
+ if command.start_with? 'git '
+ Dir.chdir HOMEBREW_REPOSITORY { `#{command}` }
+ else
+ `#{command}`
+ end
+
step.status = $?.success? ? :passed : :failed
step.puts_result
puts IO.read(step.log_file_path) if output_on_success
@@ -142,18 +149,24 @@ class Test
end
end
+ def git arguments
+ Dir.chdir HOMEBREW_REPOSITORY do
+ `git #{arguments}`
+ end
+ end
+
def download
def current_sha1
- `git rev-parse --short HEAD`.strip
+ git('rev-parse --short HEAD').strip
end
def current_branch
- `git symbolic-ref HEAD`.slice!("refs/heads/").strip
+ git('symbolic-ref HEAD').slice!("refs/heads/").strip
end
@category = __method__
if @url
- `git am --abort 2>/dev/null`
+ git 'am --abort 2>/dev/null'
test "brew update" if current_branch == "master"
@start_sha1 = current_sha1
test "brew pull --clean #{@url}"
@@ -171,7 +184,7 @@ class Test
return unless @url and @start_sha1 != end_sha1 and steps.last.status == :passed
- `git diff #{@start_sha1}..#{end_sha1} --name-status`.each_line do |line|
+ git("diff #{@start_sha1}..#{end_sha1} --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')
@@ -216,7 +229,7 @@ class Test
test "git reset --hard origin/master"
test "git clean --force -dx"
else
- `git diff --exit-code HEAD 2>/dev/null`
+ git('diff --exit-code HEAD 2>/dev/null')
odie "Uncommitted changes, aborting." unless $?.success?
test "git reset --hard #{@start_sha1}" if @start_sha1
end
@@ -273,8 +286,6 @@ if ARGV.empty?
odie 'This command requires at least one argument containing a pull request number or formula.'
end
-Dir.chdir HOMEBREW_REPOSITORY
-
ARGV.named.each do|arg|
Test.run arg
end