Last active
December 10, 2018 10:22
-
-
Save cmfcruz/bfd0b51a442dfdaf933a492ad768a00d to your computer and use it in GitHub Desktop.
Automatically increment bugfix version in a version file within the code. Create a version file if non exists. This is to have a version reference separate from git branching.
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 | |
# This script automatically updates the version number in the version.txt file | |
# if there are updated files during the commit. | |
# Enable this script using the following command: | |
# mv -f pre-commit.sh .git/hooks/pre-commit && chmod u+x .git/hooks/pre-commit | |
version_file=build.info | |
if [ `git diff --cached --name-only | wc -l` -gt 0 ] | |
then | |
if [ ! -f $version_file ] | |
then | |
cat > $version_file <<EOF | |
major=0 | |
minor=0 | |
bugfix=0 | |
EOF | |
fi | |
source $version_file | |
let bugfix++ | |
cat > $version_file <<EOF | |
major=$major | |
minor=$minor | |
bugfix=$bugfix | |
EOF | |
git add $version_file | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment