Forked from ThomDietrich/git-create-revisioninfo-hook.sh
Created
October 12, 2018 07:00
-
-
Save 5818959/2331df35aeb1fcb630bfc90bd7e19a75 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