Created
April 19, 2013 11:54
-
-
Save McRipper/5419879 to your computer and use it in GitHub Desktop.
Git Hook to increment version in file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MESSAGE="$1" | |
VERSION_PATH=`git rev-parse --show-toplevel`"/config/initializers/version.rb" | |
VER_TOKEN="Version" | |
VER_STR=$(grep "$VER_TOKEN" $VERSION_PATH | awk '{print $3}' | tr -d '"') | |
VER_MAJ=$(echo $VER_STR | awk -F. '{print $1}') | |
VER_MIN=$(echo $VER_STR | awk -F. '{print $2}') | |
VER_PAT=$(echo $VER_STR | awk -F. '{print $3}') | |
applyVersion() | |
{ | |
VER_STR=$VER_MAJ"."$VER_MIN"."$VER_PAT | |
VER_LINE=$VER_TOKEN" = "\"$VER_STR\" | |
sed -i "" 's/'"$VER_TOKEN"'.*/'"$VER_LINE"'/g' $VERSION_PATH | |
git add $VERSION_PATH | |
#git commit -m "version update: "$VER_STR | |
} | |
onVMAJ() | |
{ | |
let VER_MAJ++ | |
VER_MIN=0 | |
VER_PAT=0 | |
applyVersion | |
} | |
onVMIN() | |
{ | |
let VER_MIN++ | |
VER_PAT=0 | |
applyVersion | |
} | |
onVPAT() | |
{ | |
let VER_PAT++ | |
applyVersion | |
} | |
case "$MESSAGE" in | |
*vmaj++* ) onVMAJ;; | |
*vmin++* ) onVMIN;; | |
*vpat++* ) onVPAT;; | |
* ) onVPAT;; | |
esac | |
exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Place this file in the initializers folder | |
# Version can be called: Fashionbi::Version | |
# | |
module Fashionbi | |
Version = "3.2.1" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment