Skip to content

Instantly share code, notes, and snippets.

@giavac
Last active August 29, 2015 14:23
Show Gist options
  • Save giavac/af7f7a76dddf71ce2493 to your computer and use it in GitHub Desktop.
Save giavac/af7f7a76dddf71ce2493 to your computer and use it in GitHub Desktop.
Get tag or latest commit hash
LASTCOMMIT=$(git rev-parse --short HEAD)
CONFVERSION=$LASTCOMMIT
TAG=$(git show-ref --tags -d | grep ^${LASTCOMMIT} | sed -e 's,.* refs/tags/,,' -e 's/\^{}//')
if [ "$TAG" != "" ]
then
CONFVERSION=$TAG
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment