Forked from ThomDietrich/git-create-revisioninfo-hook.sh
Created
June 23, 2019 11:57
-
-
Save mattwood1/35a5d8a13b5899e73cabc6c2f9423979 to your computer and use it in GitHub Desktop.
git hook for revision and branch version file
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 | |
## Automatically generate a file with git branch and revision info | |
## | |
## Example: | |
## [master]v2.0.0-beta-191(a830382) | |
## Install: | |
## cp git-create-revisioninfo-hook.sh .git/hooks/post-commit | |
## cp git-create-revisioninfo-hook.sh .git/hooks/post-checkout | |
## cp git-create-revisioninfo-hook.sh .git/hooks/post-merge | |
## chmod +x .git/hooks/post-* | |
FILENAME='public/gitrevision.txt' | |
exec 1>&2 | |
branch=`git rev-parse --abbrev-ref HEAD` | |
shorthash=`git log --pretty=format:'%h' -n 1` | |
revcount=`git log --oneline | wc -l` | |
latesttag=`git describe --tags --abbrev=0` | |
VERSION="[$branch]$latesttag-$revcount($shorthash)" | |
echo $VERSION > $FILENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment