2011-11-28 17:18:23 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2015-02-08 23:36:57 +01:00
|
|
|
# Bumps the micro version according to the number of commits on this branch
|
2011-11-28 17:18:23 +01:00
|
|
|
#
|
|
|
|
# To have git run this script on commit, create a "pre-commit" text file in
|
|
|
|
# .git/hooks/ with the following content:
|
|
|
|
# #!/bin/sh
|
2011-12-09 23:47:44 +01:00
|
|
|
# if [ -x ./_pre-commit.sh ]; then
|
|
|
|
# source ./_pre-commit.sh
|
|
|
|
# fi
|
2011-11-28 17:18:23 +01:00
|
|
|
|
|
|
|
type -P sed &>/dev/null || { echo "sed command not found. Aborting." >&2; exit 1; }
|
|
|
|
type -P git &>/dev/null || { echo "git command not found. Aborting." >&2; exit 1; }
|
|
|
|
|
2012-05-16 13:17:07 +02:00
|
|
|
VER=`git log --oneline | wc -l`
|
2014-02-01 01:03:57 +01:00
|
|
|
# adjust so that we match the github commit count
|
|
|
|
TAGVER=`expr $VER + 1`
|
2015-02-08 23:36:57 +01:00
|
|
|
# there may be a better way to prevent improper micro on amend. For now the detection
|
2011-11-28 17:18:23 +01:00
|
|
|
# of a .amend file in the current directory will do
|
|
|
|
if [ -f ./.amend ]; then
|
|
|
|
TAGVER=`expr $TAGVER - 1`
|
2013-06-25 23:50:22 +02:00
|
|
|
git tag -d "b$TAGVER"
|
2011-11-28 17:18:23 +01:00
|
|
|
rm ./.amend;
|
|
|
|
fi
|
2015-02-08 23:36:57 +01:00
|
|
|
echo "setting micro to $TAGVER"
|
2011-11-30 19:45:16 +01:00
|
|
|
echo $TAGVER > .tag
|
2011-11-28 17:18:23 +01:00
|
|
|
|
|
|
|
cat > cmd.sed <<\_EOF
|
2017-04-20 13:58:04 +02:00
|
|
|
s/^\([ \t]*\)*\(FILE\|PRODUCT\)VERSION\([ \t]*\)\([0-9]*\),\([0-9]*\),[0-9]*,\(.*\)/\1\2VERSION\3\4,\5,@@TAGVER@@,\6/
|
|
|
|
s/^\([ \t]*\)VALUE\([ \t]*\)"\(File\|Product\)Version",\([ \t]*\)"\(.*\)\..*"[ \t]*/\1VALUE\2"\3Version",\4"\5.@@TAGVER@@"/
|
2015-02-08 23:36:57 +01:00
|
|
|
s/^\(.*\)"Rufus \(.*\)\..*"\(.*\)/\1"Rufus \2.@@TAGVER@@"\3/
|
2017-04-20 13:58:04 +02:00
|
|
|
s/^\([ \t]*\)Version="\([0-9]*\)\.\([0-9]*\)\.[0-9]*\.\([0-9]*\)"\(.*\)/\1Version="\2.\3.@@TAGVER@@.\4"\5/
|
2011-11-28 17:18:23 +01:00
|
|
|
_EOF
|
|
|
|
|
|
|
|
# First run sed to substitute our variable in the sed command file
|
2014-02-03 20:22:32 +01:00
|
|
|
sed -i -e "s/@@TAGVER@@/$TAGVER/g" cmd.sed
|
2011-11-28 17:18:23 +01:00
|
|
|
# Run sed to update the nano version
|
2017-04-20 13:58:04 +02:00
|
|
|
sed -b -i -f cmd.sed src/rufus.rc
|
2014-02-03 20:22:32 +01:00
|
|
|
# NB: we need to run git add else the modified files may be ignored
|
2011-12-05 12:19:05 +01:00
|
|
|
git add src/rufus.rc
|
2011-11-28 17:18:23 +01:00
|
|
|
|
2011-11-28 21:06:47 +01:00
|
|
|
rm cmd.sed
|