git rev-list HEAD | sort > config.git-hash LOCALVER=`wc -l config.git-hash | awk '{print $1}'` if [ $LOCALVER \> 1 ] ; then REVISE=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'` VERSION=`git tag` echo"$VERSION" if [ $REVISE != $LOCALVER ] ; then REVISE="$REVISE+$(($LOCALVER-$REVISE))" fi if git status | grep -q "modified:" ; then REVISE="${REVISE}" fi
if [ ! -n "$VERSION" ]; then VERSION="v1.0.0" else VERSION=`git describe --tags $(git rev-list --tags --max-count=1)` fi
GIT_HASH=`git rev-list HEAD -n 1` GIT_SHORT_HASH=`git rev-list HEAD -n 1 | cut -c 1-8` TIME=`git log --pretty=format:"%cd"$GIT_SHORT_HASH -1` echo"$TIME" else GIT_VERSION= REVISE="x"SHORT_ fi rm -f config.git-hash
cat version.template | sed "s/\$FULL_HASH/$GIT_HASH/g" | sed "s/\$FULL_REVISE/$REVISE/g" | sed "s/\$FULL_VERSION/$VERSION/g" | sed "s/\$FULL_TIME/$TIME/g" > public/$REVISE cat version.json.template | sed "s/\$FULL_HASH/$GIT_SHORT_HASH/g" | sed "s/\$FULL_REVISE/$REVISE/g" | sed "s/\$FULL_VERSION/$VERSION/g" | sed "s/\$FULL_TIME/$TIME/g" > public/version.json
echo"$VERSION.$REVISE" echo"Generated version info : $REVISE"