I am deploying my rails 3 app using capistrano, and I want to get the git version (and date information) and update my website\'s footer with this.
How can I do this? >
Often one does not deploy into a git repository, but into a release which does not contain any repository information:
Capistrano stores a revision file with each successful deployment which is the git commit sha. This file is called REVISION
and can be found in the root of the deployment directory.
In config/initializers of your Rails app, create a file: deploy_version.rb with something like:
if File.exists?('REVISION')
APP_REVISION = `cat REVISION`
else
APP_REVISION = 'unknown'
end
Or if sure that outside of deployment there is always a git repository one can replace the last assignment with
if File.exists?('REVISION')
APP_REVISION = `cat REVISION`
else
APP_REVISION = `git describe --abbrev=6 --always --tags.`
end