Include revision information in non-release version strings, if available.
This commit is contained in:
parent
28c27d27c1
commit
c54e8928d3
2 changed files with 88 additions and 1 deletions
|
@ -12,7 +12,7 @@
|
||||||
#
|
#
|
||||||
# this defines the CORE version number, must be static for AC_INIT
|
# this defines the CORE version number, must be static for AC_INIT
|
||||||
#
|
#
|
||||||
AC_INIT(core, 4.8dev1, core-dev@pf.itd.nrl.navy.mil)
|
AC_INIT(core, m4_esyscmd_s([./revision.sh 4.8]), core-dev@pf.itd.nrl.navy.mil)
|
||||||
VERSION=$PACKAGE_VERSION
|
VERSION=$PACKAGE_VERSION
|
||||||
CORE_VERSION=$PACKAGE_VERSION
|
CORE_VERSION=$PACKAGE_VERSION
|
||||||
CORE_VERSION_DATE=20150605
|
CORE_VERSION_DATE=20150605
|
||||||
|
|
87
revision.sh
Executable file
87
revision.sh
Executable file
|
@ -0,0 +1,87 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "usage: $(basename $0) <base version>" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git_revision()
|
||||||
|
{
|
||||||
|
local ver describe commits branch sha dirty
|
||||||
|
|
||||||
|
ver=$1
|
||||||
|
|
||||||
|
describe=$(git describe --tags --dirty 2> /dev/null)
|
||||||
|
if [ "$describe" ]; then
|
||||||
|
echo "$describe" | sed -e 's/^release-//'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! "$(git tag -l release-$ver)" ]; then
|
||||||
|
ver="unknown"
|
||||||
|
else
|
||||||
|
commits=$(git rev-list release-${ver}^..HEAD | wc -l)
|
||||||
|
if [ $commits -eq 0 ]; then
|
||||||
|
commits=""
|
||||||
|
else
|
||||||
|
commits=".$commits"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
if [ "$branch" = master ]; then
|
||||||
|
branch=""
|
||||||
|
else
|
||||||
|
branch=".$(echo -n $branch | tr -sC '.[:alnum:]' '[.*]')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ver" = "unknown" -o "$commits" ]; then
|
||||||
|
sha=.g$(git log -1 --pretty="%h")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! git diff --quiet; then
|
||||||
|
dirty=".dirty"
|
||||||
|
else
|
||||||
|
dirty=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ${ver}${commits}${branch}${sha}${dirty}
|
||||||
|
}
|
||||||
|
|
||||||
|
svn_revision()
|
||||||
|
{
|
||||||
|
local ver tagrev commits rev dirty
|
||||||
|
|
||||||
|
ver=$1
|
||||||
|
|
||||||
|
tagrev=$(svn log -q ^/tags/release-$ver --limit 1 2> /dev/null | \
|
||||||
|
awk '/^r/ {print $1}')
|
||||||
|
if [ ! "$tagrev" ];then
|
||||||
|
ver="unknown"
|
||||||
|
else
|
||||||
|
commits=$(svn log -q -r $tagrev:HEAD | grep '^r' | wc -l)
|
||||||
|
if [ $commits -eq 0 ]; then
|
||||||
|
commits=""
|
||||||
|
else
|
||||||
|
commits=".$commits"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$ver" = "unknown" -o "$commits" ]; then
|
||||||
|
rev=.s$(svn info | awk '/^Revision:/ {print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (svn status -q | grep -q .); then
|
||||||
|
dirty=".dirty"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ${ver}${commits}${rev}${dirty}
|
||||||
|
}
|
||||||
|
|
||||||
|
if test -d .git || git rev-parse --git-dir > /dev/null 2>&1; then
|
||||||
|
git_revision "$@"
|
||||||
|
elif test -d .svn || svn info > /dev/null 2>&1; then
|
||||||
|
svn_revision "$@"
|
||||||
|
else
|
||||||
|
echo "$@"
|
||||||
|
fi
|
Loading…
Reference in a new issue