1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Use correct source for query_revision [#4 tagged:committed state:resolved]

This commit is contained in:
Jamis Buck 2008-04-24 22:37:02 -06:00
parent d11006102c
commit ec9a7fa52c
3 changed files with 15 additions and 3 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* For query_revision, git SCM used git-rev-parse on the repo hosting the Capfile, which may NOT be the same tree as the actual source reposistory. Use git-ls-remote instead to resolve the revision for checkout. [Robin H. Johnson]
* Allow :ssh_options hash to be specified per server [Jesse Newland]
* Added support for depend :remote, :file to test for existence of a specific file [Andrew Carter]

View file

@ -192,7 +192,13 @@ module Capistrano
# Getting the actual commit id, in case we were passed a tag
# or partial sha or something - it will return the sha if you pass a sha, too
def query_revision(revision)
yield(scm('rev-parse', revision)).chomp
return revision if revision =~ /^[0-9a-f]{40}$/
command = scm('ls-remote', repository, revision)
result = yield(command)
revdata = result.split("\t")
newrev = revdata[0]
raise "Unable to resolve revision for #{revision}" unless newrev =~ /^[0-9a-f]{40}$/
return newrev
end
def command

View file

@ -7,7 +7,7 @@ class DeploySCMGitTest < Test::Unit::TestCase
end
def setup
@config = { }
@config = { :repository => "." }
def @config.exists?(name); key?(name); end
@source = TestSCM.new(@config)
@ -50,7 +50,11 @@ class DeploySCMGitTest < Test::Unit::TestCase
end
def test_query_revision
assert_equal "git rev-parse HEAD", @source.query_revision('HEAD') { |o| o }
revision = @source.query_revision('HEAD') do |o|
assert_equal "git ls-remote . HEAD", o
"d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD"
end
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
end
def test_command_should_be_backwards_compatible