Skip to content

Instantly share code, notes, and snippets.

@briandk
Created May 16, 2012 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandk/2712160 to your computer and use it in GitHub Desktop.
Save briandk/2712160 to your computer and use it in GitHub Desktop.
precommit hook for granovaGG git repository
#!/bin/bash
D=`date +%Y%m%d%H%M%S` # store the current system-clock as a date-stamp, down to the second
branch=`git status|grep -ie 'on branch master'`
if [ -z "$branch" ]; then # if the length of the string in variable "branch" is zero;
# or, in other words, if you're not on the master branch
cat DESCRIPTION | sed -e 's/^\(Version: [0-9]*\.[0-9]*\).*/\1.'$D'/' > DESCRIPTION.temp # cat the DESCRIPTION
# match on the version number
# append the full datestamp to the matched version number
# redirect the output to a temporary file
rm DESCRIPTION # trash the original DESCRIPTION
mv DESCRIPTION.temp DESCRIPTION # rename the temp file to DESCRIPTION
git add DESCRIPTION # stage the now-modified DESCRIPTION file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment