I am using capistrano to deploy a RoR application. The codebase is in a git repository, and branching is widely used in development. Capistrano uses deploy.rb f
Using Capistrano 3.1.0+, none of these were working for me anymore. Instead, according to their commented instructions:
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
But, you don't want to use ask or it will prompt you. Instead you should use set. HEAD is the top most branch; 'edge' as it's called. If you want a different branch, replace HEAD with your branch name, eg: master, staging, etc.
To conclude with examples, in /config/deploy/production.rb, you might include this line:
set :branch, proc { `git rev-parse --abbrev-ref master`.chomp }
...or
set :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
btw, HEAD is the default setting, so no need to really state that in file. Might be used better in a /config/deploy/edge.rb.
In /config/deploy/staging.rb, you might include this line:
set :branch, proc { `git rev-parse --abbrev-ref staging`.chomp }
...or
set :branch, proc { `git rev-parse --abbrev-ref test`.chomp }
You get the idea!
I hope these examples help future users of capistrano (^_^)