Created
September 30, 2009 17:27
-
-
Save mhaley/198268 to your computer and use it in GitHub Desktop.
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
# Call +git+ and obtain the current commit SHA1 and commit date. Store these values | |
# in +APP_VERSION_COMMIT_ID+ and +APP_VERSION_COMMIT_DATE+. Then define | |
# +APP_VERSION+ to be a string of the two. | |
git_cmd = 'git show --pretty=format:"%H|%ci" --quiet' | |
commit_id = nil | |
commit_date = nil | |
begin | |
unless RAILS_ENV=='test' | |
commit_id, commit_date = IO.popen(git_cmd) {|f| | |
log_entry = f.gets | |
log_entry.split("|") unless log_entry.nil? | |
} | |
else | |
commit_id, commit_date = '','' | |
end | |
rescue Errno::ENOENT # git not installed | |
commit_id = 'Unknown' | |
commit_date = '' | |
end | |
unless defined?(::APP_VERSION) | |
APP_VERSION_COMMIT_ID = commit_id | |
APP_VERSION_COMMIT_DATE = commit_date | |
APP_VERSION = "#{commit_id} #{commit_date}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment