Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/timcharper/capistrano into …
Browse files Browse the repository at this point in the history
…timcharper/master
  • Loading branch information
jamis committed May 25, 2008
2 parents 19e6e3b + 3777ddc commit a70629e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/capistrano/recipes/deploy/scm/git.rb
Expand Up @@ -208,12 +208,13 @@ def log(from, to=nil)
# 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)
raise ArgumentError, "Deploying remote branches has been deprecated. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{revision.gsub('origin/', '')}' rather than '#{revision}')." if revision =~ /^origin\//
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}$/
raise "Unable to resolve revision for '#{revision}' on repository '#{repository}'." unless newrev =~ /^[0-9a-f]{40}$/
return newrev
end

Expand Down
6 changes: 6 additions & 0 deletions test/deploy/scm/git_test.rb
Expand Up @@ -57,6 +57,12 @@ def test_query_revision
assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
end

def test_query_revision_deprecation_error
assert_raise(ArgumentError) do
revision = @source.query_revision('origin/release') {}
end
end

def test_command_should_be_backwards_compatible
# 1.x version of this module used ":git", not ":scm_command"
@config[:git] = "/srv/bin/git"
Expand Down

0 comments on commit a70629e

Please sign in to comment.