Before trying to update, first checkout the masterbrew branch.

This commit is contained in:
Eloy Duran committed 2009-09-17 00:24:11 +02:00
1 parent 0fa5dc02a9
commit 10e83c2a2c
2 files changed
+25 -5

No files matched your search

+6
View File
@@ -1,4 +1,5 @@
class RefreshBrew
CHECKOUT_COMMAND = 'git checkout masterbrew'
UPDATE_COMMAND = 'git pull origin masterbrew'
REVISION_COMMAND = 'git log -l -1 --pretty=format:%H'
GIT_UP_TO_DATE = 'Already up-to-date.'
@@ -13,6 +14,7 @@ class RefreshBrew
# Performs an update of the homebrew source. Returns +true+ if a newer
# version was available, +false+ if already up-to-date.
def update_from_masterbrew!
git_checkout_masterbrew!
output = git_pull!
output.split("\n").each do |line|
@updated_formulae << $1 if line =~ UPDATED_FORMULA
@@ -34,6 +36,10 @@ class RefreshBrew
Dir.chdir(HOMEBREW_PREFIX) { yield }
end
def git_checkout_masterbrew!
in_prefix { `#{CHECKOUT_COMMAND}` }
end
def git_pull!
in_prefix { `#{UPDATE_COMMAND}` }
end
+19 -5
View File
@@ -84,17 +84,27 @@ class TestScriptFileFormula <ScriptFileFormula
end
class RefreshBrewMock < RefreshBrew
def in_prefix_expect(expect, returns)
@expect, @returns = expect, returns
def in_prefix_expect(expect, returns = '')
@expect ||= {}
@expect[expect] = returns
end
def `(cmd)
if Dir.pwd == HOMEBREW_PREFIX.to_s and cmd == @expect
@returns
if Dir.pwd == HOMEBREW_PREFIX.to_s and @expect.has_key?(cmd)
(@called ||= []) << cmd
@expect[cmd]
else
raise "<#{inspect}> Called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
raise "#{inspect} Unexpectedly called backticks in pwd `#{HOMEBREW_PREFIX}' and command `#{cmd}'"
end
end
def expectations_met?
@expect.keys == @called
end
def inspect
"#<#{self.class.name} #{object_id}>"
end
end
def nostdout
@@ -504,9 +514,11 @@ class BeerTasting <Test::Unit::TestCase
def test_updater_update_homebrew_without_any_changes
outside_prefix do
updater = RefreshBrewMock.new
updater.in_prefix_expect("git checkout masterbrew")
updater.in_prefix_expect("git pull origin masterbrew", "Already up-to-date.\n")
assert_equal false, updater.update_from_masterbrew!
assert updater.expectations_met?
assert updater.updated_formulae.empty?
end
end
@@ -514,6 +526,7 @@ class BeerTasting <Test::Unit::TestCase
def test_updater_update_homebrew_without_formulae_changes
outside_prefix do
updater = RefreshBrewMock.new
updater.in_prefix_expect("git checkout masterbrew")
output = fixture('update_git_pull_output_without_formulae_changes')
updater.in_prefix_expect("git pull origin masterbrew", output)
@@ -526,6 +539,7 @@ class BeerTasting <Test::Unit::TestCase
def test_updater_update_homebrew_with_formulae_changes
outside_prefix do
updater = RefreshBrewMock.new
updater.in_prefix_expect("git checkout masterbrew")
output = fixture('update_git_pull_output_with_formulae_changes')
updater.in_prefix_expect("git pull origin masterbrew", output)