Created
January 19, 2009 12:14
-
-
Save matthewford/48967 to your computer and use it in GitHub Desktop.
Git SHA1 of HEAD in your Rails App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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