Skip to content

Instantly share code, notes, and snippets.

@nilz3ro
Last active June 5, 2017 19:20
Show Gist options
  • Save nilz3ro/de0fc2f16d8a28fb98163a81bc30b75f to your computer and use it in GitHub Desktop.
Save nilz3ro/de0fc2f16d8a28fb98163a81bc30b75f to your computer and use it in GitHub Desktop.
Add the latest commit hash to a given file, as an html comment.
require 'fileutils'
class CommitCommenter
def initialize(git_project_path)
@project_path = git_project_path.chomp
end
def latest_commit_hash
FileUtils.cd(@project_path)
return `git rev-parse HEAD`.chomp
end
def comment
"<!-- #{latest_commit_hash} -->"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment