Skip to content

Instantly share code, notes, and snippets.

@carcer
Created January 16, 2013 10:06
Show Gist options
  • Save carcer/4546067 to your computer and use it in GitHub Desktop.
Save carcer/4546067 to your computer and use it in GitHub Desktop.
def get_commit_hash_and_date
begin
commit = `git log -1 --pretty=format:%H`
git_date = `git log -1 --date=iso --pretty=format:%ad`
branch = `git rev-parse --abbrev-ref HEAD`
commit_date = DateTime.parse( git_date ).strftime("%Y-%m-%d %H%M%S")
rescue
commit = ENV["BUILD_VCS_NUMBER"]
end
[commit, commit_date, branch]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment