Last active
June 5, 2017 19:20
-
-
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.
This file contains hidden or 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
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