Created
November 24, 2011 15:15
-
-
Save finestructure/1391557 to your computer and use it in GitHub Desktop.
Bash script to report a git repositories version for further use like embedding as a version string
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
#!/bin/bash | |
git status | |
version=$(git describe --tags --dirty) | |
# version can be empty when there are no tags, use rev-parse in that case | |
# to log the last commit id | |
if [[ -z "$version" ]]; then | |
diff=$(git diff) | |
version=$(git rev-parse --short HEAD) | |
if [[ -n "$diff" ]]; then | |
version=${version}-dirty | |
fi | |
fi | |
echo version: $version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment