diff --git a/lib/capistrano/recipes/deploy/scm/git.rb b/lib/capistrano/recipes/deploy/scm/git.rb index a3bbe7637..7499e49f0 100644 --- a/lib/capistrano/recipes/deploy/scm/git.rb +++ b/lib/capistrano/recipes/deploy/scm/git.rb @@ -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 diff --git a/test/deploy/scm/git_test.rb b/test/deploy/scm/git_test.rb index 5a27acb25..1f8a473e7 100644 --- a/test/deploy/scm/git_test.rb +++ b/test/deploy/scm/git_test.rb @@ -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"