02 June 2008

Fixing Capistrano 2.3.0 and Git Deploy Problem

If you upgrade to Capistrano 2.3.0, and are doing deploys from a Git repository, you may find that all of a sudden you can no longer deploy. This is the case if you have no tags in your Git repo. Cap 2.3.0 changed one of the Git commands it uses and that apparently doesn't work right if you don't have tags. So, to solve the problem, you can simply create a single tag in your Git repository. The tag does not have to relate to your build at all, you only need one tag in the repo (not one per build or anything like that), etc. Once you create the tag, you can now deploy again.

To create a tag in Git, or, I think the "cooler" kind of tag, an annotated tag, you can do:

git tag -a tag_name

Replace "tag_name" with your tag name of course. The "-a" option says to make it an annotated tag, which lets you enter a comment about the tag. You can put whatever you want in there. I'm liking this potential use with my continuous integration server when it makes tags on successful builds. Lots of possibilities.

Finally, if you deploy from a remote repo, or if you have a remote repo (say on GitHub), you will need to push your tag. This does not automatically occur on a push, you need to add "--tags" option to git-push to include your tags:

git push --tags

Now you'll have your tags on your remote repo, and listed under the "all tags" tab on GitHub.


Anonymous said...

cool, just what I needed. Thanks!

stjohn said...

new version of capistrano just released... fixes this problem!


Chris said...

stjohn, where are you seeing a new version? The usual places are showing 2.3 still: GitHub shows the code at 2.3 still, as does the official Cap site, Jasmis' blog doesn't say anything, and doing a gem update on it does not pull anything down. 2.3 appears to still be latest from what I'm seeing.

Anonymous said...

Hi Chris,
check out the google groups capistrano list. It is a pre release you can get from
Jamis's web site. Please email me if you need to. stjohn@kid-safe.co.uk

It fixes all the problems I have been having (tracking edge with submodules...)