From 3777ddcd57dc7729f6a491382815fb59ebfa5d1a Mon Sep 17 00:00:00 2001 From: Tim Harper Date: Fri, 16 May 2008 14:21:06 -0600 Subject: [PATCH] Display a deprecation error if a remote git branch is specified Capistrano 2.2 allowed you to do this: set :branch, "origin/release" In capistrano 2.3, the correct syntax is now: set :branch, "release" This change will cause capistrano to show a helpful error message for those upgraders who have been using the 'origin/release' syntax. --- lib/capistrano/recipes/deploy/scm/git.rb | 3 ++- test/deploy/scm/git_test.rb | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/capistrano/recipes/deploy/scm/git.rb b/lib/capistrano/recipes/deploy/scm/git.rb index a3bbe763..7499e49f 100644 --- a/lib/capistrano/recipes/deploy/scm/git.rb +++ b/lib/capistrano/recipes/deploy/scm/git.rb @@ -208,12 +208,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) + 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 5a27acb2..1f8a473e 100644 --- a/test/deploy/scm/git_test.rb +++ b/test/deploy/scm/git_test.rb @@ -57,6 +57,12 @@ class DeploySCMGitTest < Test::Unit::TestCase 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"