2011-11-28 16:18:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Bumps the nano version according to the number of commits on this branch
|
|
|
|
#
|
|
|
|
# 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 grep &>/dev/null || { echo "grep command not found. Aborting." >&2; exit 1; }
|
|
|
|
type -P git &>/dev/null || { echo "git command not found. Aborting." >&2; exit 1; }
|
|
|
|
|
|
|
|
VER=`git shortlog | grep -E '^[ ]+' | wc -l`
|
|
|
|
# trim spaces
|
|
|
|
TAGVER=`echo $VER`
|
|
|
|
# there may be a better way to prevent improper nano on amend. For now the detection
|
|
|
|
# of a .amend file in the current directory will do
|
|
|
|
if [ -f ./.amend ]; then
|
|
|
|
TAGVER=`expr $TAGVER - 1`
|
2011-11-30 18:45:16 +00:00
|
|
|
git tag -d "#$TAGVER"
|
2011-11-28 16:18:23 +00:00
|
|
|
rm ./.amend;
|
|
|
|
fi
|
|
|
|
echo "setting nano 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
|
|
|
|
s/^[ \t]*FILEVERSION[ \t]*\(.*\),\(.*\),\(.*\),.*/ FILEVERSION \1,\2,\3,@@TAGVER@@/
|
|
|
|
s/^[ \t]*PRODUCTVERSION[ \t]*\(.*\),\(.*\),\(.*\),.*/ PRODUCTVERSION \1,\2,\3,@@TAGVER@@/
|
|
|
|
s/^\([ \t]*\)VALUE[ \t]*"FileVersion",[ \t]*"\(.*\)\..*"/\1VALUE "FileVersion", "\2.@@TAGVER@@"/
|
|
|
|
s/^\([ \t]*\)VALUE[ \t]*"ProductVersion",[ \t]*"\(.*\)\..*"/\1VALUE "ProductVersion", "\2.@@TAGVER@@"/
|
2011-12-07 00:28:27 +00:00
|
|
|
# TODO: revert ' ' to '"' below when out of beta
|
2011-12-12 21:14:33 +00:00
|
|
|
s/^\(.*\)"Rufus v\(.*\)\.\(.*\)"\(.*\)/\1"Rufus v\2.@@TAGVER@@"\4/
|
2011-11-28 16:18:23 +00:00
|
|
|
s/^\(.*\)"Version \(.*\) (Build \(.*\))"\(.*\)/\1"Version \2 (Build @@TAGVER@@)"\4/
|
|
|
|
_EOF
|
|
|
|
|
|
|
|
# First run sed to substitute our variable in the sed command file
|
|
|
|
sed -e "s/@@TAGVER@@/$TAGVER/g" cmd.sed > cmd.sed~
|
|
|
|
mv cmd.sed~ cmd.sed
|
|
|
|
|
|
|
|
# Run sed to update the nano version
|
|
|
|
# NB: we need to run git add else the modified files may be ignored
|
2011-12-05 11:19:05 +00:00
|
|
|
sed -f cmd.sed src/rufus.rc > 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
|
2011-12-05 11:19:05 +00:00
|
|
|
sed 's/$/\r/' src/rufus.rc~ > src/rufus.rc
|
|
|
|
rm src/rufus.rc~
|
|
|
|
git add src/rufus.rc
|
2011-11-28 16:18:23 +00:00
|
|
|
|
2011-11-28 20:06:47 +00:00
|
|
|
rm cmd.sed
|