From d35d37cf20064e8b1c917f4ac2a4a531ddb90544 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Mon, 28 Nov 2011 16:18:23 +0000 Subject: [PATCH] [internal] added pre-commit git script to increase the nano * from now on, nano will reflect the distance to initial commit * to have git run this script on commit, create a "pre-commit" in .git/hooks/ with the following content: #!/bin/sh source ./_pre-commit.sh --- _pre-commit.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ rufus.h | 2 +- rufus.rc | 10 +++++----- 3 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 _pre-commit.sh diff --git a/_pre-commit.sh b/_pre-commit.sh new file mode 100644 index 00000000..344fceaa --- /dev/null +++ b/_pre-commit.sh @@ -0,0 +1,53 @@ +#!/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` + rm ./.amend; +fi +echo "setting nano to $TAGVER" + +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@@"/ +s/^\(.*\)ufus v\(.*\)\.\(.*\)"\(.*\)/\1ufus v\2.@@TAGVER@@"\4/ +s/^zadig_version=\(.*\)\..*/rufus_version=\1.@@TAGVER@@/ +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~ +mv ./rufus.rc~ ./rufus.rc +git add ./rufus.rc +sed -f cmd.sed ./rufus.h > ./rufus.h~ +mv ./rufus.h~ ./rufus.h +git add ./rufus.h +#sed -f cmd.sed _bm.sh > _bm.sh~ +#mv _bm.sh~ _bm.sh + +# TODO?: use the following in post-commit to setup a tag every 10 commits +#if [ "${TAGVER:${#TAGVER}-1:1}" == '0' ]; then +# echo " commit #${TAGVER:${#TAGVER}-1:1}"; +#fi diff --git a/rufus.h b/rufus.h index c9272904..8efa5b14 100644 --- a/rufus.h +++ b/rufus.h @@ -21,7 +21,7 @@ #define RUFUS_DEBUG -#define APP_VERSION "Rufus v1.0.0.1" +#define APP_VERSION "Rufus v1.0.0.41" #define STR_NO_LABEL "NO_LABEL" #define RUFUS_CANCELBOX_TITLE "Rufus - Cancellation" #define DRIVE_INDEX_MIN 0x80 diff --git a/rufus.rc b/rufus.rc index 2add426c..9a85cd42 100644 --- a/rufus.rc +++ b/rufus.rc @@ -63,7 +63,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "https://github.com/pbatard/rufus",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.0.0.1",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.0.0 (Build 41)",IDC_STATIC,46,19,78,8 PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 @@ -162,8 +162,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 + FILEVERSION 1,0,0,41 + PRODUCTVERSION 1,0,0,41 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -180,13 +180,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.0.0.1" + VALUE "FileVersion", "1.0.0.41" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.0.0.1" + VALUE "ProductVersion", "1.0.0.41" END END BLOCK "VarFileInfo"