version.sh
637 字节
#!/bin/bash
rm -f src/version.h
git rev-list HEAD | sort > git_rev_list
LOCALVER=`wc -l git_rev_list | awk '{print $1}'`
BRANCH=$(git branch | grep "\*" | awk '{print $2}')
echo branch:$BRANCH
if [ $LOCALVER -ge 1 ] ; then
VER=${LOCALVER}
if git status | grep -q "modified:" ; then
VER="${VER}M"
fi
GIT_VERSION="$BRANCH r$VER $(git rev-list HEAD -n 1 | cut -c 1-8)"
else
GIT_VERSION="$BRANCH none"
fi
rm -f git_rev_list
GIT_VERSION="${GIT_VERSION} $(date "+%Y-%m-%d %H:%M:%S")"
cat scripts/version.h.tmpl | sed "s/\$FULL_VERSION/\"$GIT_VERSION\"/g" > objs/version.h
echo "save to version.h:$GIT_VERSION"