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