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
|
2015-02-08 22:36:57 +00:00
|
|
|
s/^[ \t]*FILEVERSION[ \t]*\(.*\),\(.*\),.*,\(.*\)/ FILEVERSION \1,\2,@@TAGVER@@,\3/
|
|
|
|
s/^[ \t]*PRODUCTVERSION[ \t]*\(.*\),\(.*\),.*,\(.*\)/ PRODUCTVERSION \1,\2,@@TAGVER@@,\3/
|
2011-11-28 16:18:23 +00:00
|
|
|
s/^\([ \t]*\)VALUE[ \t]*"FileVersion",[ \t]*"\(.*\)\..*"/\1VALUE "FileVersion", "\2.@@TAGVER@@"/
|
|
|
|
s/^\([ \t]*\)VALUE[ \t]*"ProductVersion",[ \t]*"\(.*\)\..*"/\1VALUE "ProductVersion", "\2.@@TAGVER@@"/
|
2015-02-08 22:36:57 +00:00
|
|
|
s/^\(.*\)"Rufus \(.*\)\..*"\(.*\)/\1"Rufus \2.@@TAGVER@@"\3/
|
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
|
2014-02-03 19:22:32 +00:00
|
|
|
sed -i -f cmd.sed src/rufus.rc
|
2011-11-29 22:53:00 +00:00
|
|
|
# MinGW's sed has the bad habit of eating CRLFs - make sure we keep 'em
|
2014-02-03 19:22:32 +00:00
|
|
|
sed -i 's/$/\r/' src/rufus.rc
|
|
|
|
# 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
|