Created
December 8, 2011 20:53
-
-
Save whylom/1448530 to your computer and use it in GitHub Desktop.
Ruby method that shells out to git describe and formats results
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
def get_tag_info(commit) | |
info = `git describe --tags #{commit}`.chomp | |
if info[/(.*)-(\d+)-g([a-z0-9]{7})/] | |
matches = Regexp.last_match | |
last_tag = matches[1] | |
commits_since_tag = matches[2] | |
noun = (commits_since_tag.to_i == 1) ? 'commit' : 'commits' | |
"#{last_tag} + #{commits_since_tag} #{noun}" | |
else | |
info | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment