Advertisement
imehesz

git pre-commit

Feb 23rd, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #!/bin/sh
  2. # make sure the script, named pre-commit, is in .git/hooks/ and is executable!
  3. EXIT_STATUS=1;
  4. MAIN_LAYOUT_FILE="path/to/main/layout.html._or_what_have_you";
  5. DATE_VERSION=`date '+%Y.%m%d.%H%M'`
  6.  
  7. if [ -e $MAIN_LAYOUT_FILE ]
  8. then
  9.   `sed -i "s/<span id='VERSION_ID'>.*<\/span>/<span id='VERSION_ID'>$DATE_VERSION<\/span>/" $MAIN_LAYOUT_FILE`;
  10.   EXIT_STATUS=0;
  11. else
  12.   echo "Missing layout file: $MAIN_LAYOUT_FILE\n";
  13. fi
  14.  
  15. # if EXIT_STATUS != 0 it will stop the whole commit
  16. exit $EXIT_STATUS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement