Uses this example format: v2.1.102 (13a02b0)
where
v2.1
is last tag102
is the number of commits made13a02b0
is the shortened hash of the last commit
If repo is not tagged, v0
will be used as default.
Write version info to VERSION
file in the repo root
.git/hooks/post-commit
#!/bin/bash
VER=`git describe --tags 2>/dev/null`
VER=${VER:-v0}
REVHASH=`git rev-parse --short HEAD`
REV=`git log --oneline | wc -l | tr -d " "`
echo "$VER.$REV ($REVHASH)" > VERSION
You may ignore this example as it also includes a line for
checkout
as a part of my deployment process.
Write version info to VERSION
file in the checkout directory defined by $DIR
variable.
$DIR
variable is the live
directory in the example below, which suits very well to my deployment process described my git-deploy-checkout.md
gist.
/home/user/website.com/stag/git/hooks/post-receive
#!/bin/sh
DIR=../live
GIT_WORK_TREE=$DIR git checkout -f
VER=`git describe --tags 2>/dev/null`
VER=${VER:-v0}
REVHASH=`git rev-parse --short HEAD`
REV=`git log --oneline | wc -l | tr -d " "`
echo "$VER.$REV ($REVHASH)" > $DIR/VERSION