public
Description: Remote multi-server automation tool. This repository is no longer being actively maintained. Please ask on the mailing list to find someone who has a well-maintained fork. Thanks!
Homepage: http://www.capify.org
Clone URL: git://github.com/jamis/capistrano.git
Use correct source for query_revision [#4 tagged:committed state:resolved]
Jamis Buck (author)
Thu Apr 24 21:37:02 -0700 2008
commit  ec9a7fa52c9f417a9a01a7e764b520be1ec32c5c
tree    5d4923fd42a60cb46d398fc44384998628f6c562
parent  d11006102c07c94e5d54dd0ee63dca825c93ed61
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* 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]
0
+
0
 * Allow :ssh_options hash to be specified per server [Jesse Newland]
0
 
0
 * Added support for depend :remote, :file to test for existence of a specific file [Andrew Carter]
...
192
193
194
195
 
 
 
 
 
 
 
196
197
198
...
192
193
194
 
195
196
197
198
199
200
201
202
203
204
0
@@ -192,7 +192,13 @@ module Capistrano
0
         # Getting the actual commit id, in case we were passed a tag
0
         # or partial sha or something - it will return the sha if you pass a sha, too
0
         def query_revision(revision)
0
-          yield(scm('rev-parse', revision)).chomp
0
+          return revision if revision =~ /^[0-9a-f]{40}$/
0
+          command = scm('ls-remote', repository, revision)
0
+          result = yield(command)
0
+          revdata = result.split("\t")
0
+          newrev = revdata[0]
0
+          raise "Unable to resolve revision for #{revision}" unless newrev =~ /^[0-9a-f]{40}$/
0
+          return newrev
0
         end
0
 
0
         def command
...
7
8
9
10
 
11
12
13
...
50
51
52
53
 
 
 
 
 
54
55
56
...
7
8
9
 
10
11
12
13
...
50
51
52
 
53
54
55
56
57
58
59
60
0
@@ -7,7 +7,7 @@ class DeploySCMGitTest < Test::Unit::TestCase
0
   end
0
 
0
   def setup
0
-    @config = { }
0
+    @config = { :repository => "." }
0
     def @config.exists?(name); key?(name); end
0
 
0
     @source = TestSCM.new(@config)
0
@@ -50,7 +50,11 @@ class DeploySCMGitTest < Test::Unit::TestCase
0
   end
0
 
0
   def test_query_revision
0
-    assert_equal "git rev-parse HEAD", @source.query_revision('HEAD') { |o| o }
0
+    revision = @source.query_revision('HEAD') do |o|
0
+      assert_equal "git ls-remote . HEAD", o
0
+      "d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD"
0
+    end
0
+    assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision
0
   end
0
 
0
   def test_command_should_be_backwards_compatible

Comments

timcharper Fri May 16 13:00:36 -0700 2008

:)

This changeset appears introduced issues for me.

The argument ‘revision’ is being passed in with a value of “origin/switchboard_base” (the name of the branch I’m deploying), which results in the execution of the command:

git ls-remote git@market:/var/gitrepo/market origin/switchboard_base

This command returns absolutely nothing. If I change the command to:

git ls-remote git@market:/var/gitrepo/market switchboard_base

It does do something. Very likely an issue with this command, which used to work in 2.2.x:

set :branch, “origin/switchboard_base”

So, based on this, I guess I should no longer be passing in remote branch names.

I’ll fork and add a change that will warn if the remote revision is unresolvable. Overall, this is an exciting change – We’ve had issues before with deploying without first fetching.

Thanks, Tim