Skip to content

Instantly share code, notes, and snippets.

@matthewford
Created January 19, 2009 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save matthewford/48967 to your computer and use it in GitHub Desktop.
Save matthewford/48967 to your computer and use it in GitHub Desktop.
Git SHA1 of HEAD in your Rails App
after "deploy:update_code", "deploy:write_sha1"
namespace :deploy do
desc "write sha1 to file"
task :write_sha1 do
run "cd #{latest_release} && git show-ref --heads --hash=7 > #{latest_release}/config/HEAD"
end
end
git_sha1_path = "#{RAILS_ROOT}/config/HEAD"
GIT_SHA1 = if File.file?(git_sha1_path)
File.open(git_sha1_path).readlines[0]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment