Last active
June 16, 2020 20:33
-
-
Save JunaidQadirB/5f67918e64dfe0357fc3dcee5df85730 to your computer and use it in GitHub Desktop.
This shell script gives you the ability to get your git the version as well as the commit hash pretty easily, via two handy utility functions
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 | |
#Get Version | |
version() { | |
git ls-remote --tags $1 | awk -F/ '{ print $3 }' | tail -n1 | |
} | |
# Get commit hash | |
hash() { | |
git ls-remote --tags $1 | awk -F/ '{ print substr($1,0,7) }' | tail -n1 | |
} | |
case $1 in | |
version) | |
"$@" | |
exit | |
;; | |
commit) | |
"$@" | |
exit | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment