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
|
|
|
|
# source ./_pre-commit.sh
|
|
|
|
|
|
|
|
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-04 20:48:07 +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
|
|
|
|
sed -f cmd.sed ./rufus.rc > ./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-11-29 20:25:29 +00:00
|
|
|
sed 's/$/\r/' ./rufus.rc~ > ./rufus.rc
|
|
|
|
rm ./rufus.rc~
|
2011-11-28 16:18:23 +00:00
|
|
|
git add ./rufus.rc
|
|
|
|
#sed -f cmd.sed _bm.sh > _bm.sh~
|
|
|
|
#mv _bm.sh~ _bm.sh
|
|
|
|
|
2011-11-28 20:06:47 +00:00
|
|
|
rm cmd.sed
|