Skip to content

Commit

Permalink
Display a deprecation error if a remote git branch is specified
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
timcharper committed May 16, 2008
1 parent 32d0b9a commit 3777ddc
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 3777ddc

Please sign in to comment.