1
0
mirror of https://github.com/inofix/maestro.git synced 2026-02-05 09:45:05 +01:00
Files
maestro/git-hooks/pre-commit
Michael Lustenberger 0c6161a31a Comments
Improved explanation of usage for the hook.
2018-07-03 15:01:55 +02:00

27 lines
872 B
Bash
Executable File

#!/bin/sh
# This is a simple solution to always update the version if the main script
# changes.. Just link this script into your .git/hooks directory and make
# sure the repo was tagged prior to your next commit!
# If someone has a better idea, please send it to me (mic at inofix.ch).
file=maestro.sh
if ! git diff --quiet HEAD $file ; then
# this means there are actually changes in the main script
if git diff --quiet $file ; then
# this means all changes are added
new_version=$(git describe)
old_version=$(grep "^#\*\* Version: .*$" $file | awk '{print $3}')
if [ "$new_version" != "$old_version" ] ; then
echo "The main script has changed, number up the version to $new_version"
sed -i 's;^#\*\* Version: .*$;#** Version: '${new_version}';' $file
git add $file
fi
fi
fi