Improve generating version strings when versions are not tagged.
This commit is contained in:
parent
adbbafcc11
commit
4b7d6a5d5a
1 changed files with 8 additions and 8 deletions
16
revision.sh
16
revision.sh
|
@ -7,7 +7,7 @@ fi
|
||||||
|
|
||||||
git_revision()
|
git_revision()
|
||||||
{
|
{
|
||||||
local ver describe commits branch sha dirty
|
local ver describe untagged commits branch sha dirty
|
||||||
|
|
||||||
ver=$1
|
ver=$1
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ git_revision()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "$(git tag -l release-$ver)" ]; then
|
if [ ! "$(git tag -l release-$ver)" ]; then
|
||||||
ver="unknown"
|
untagged=".untagged"
|
||||||
else
|
else
|
||||||
commits=$(git rev-list release-${ver}^..HEAD | wc -l)
|
commits=$(git rev-list release-${ver}^..HEAD | wc -l)
|
||||||
if [ $commits -eq 0 ]; then
|
if [ $commits -eq 0 ]; then
|
||||||
|
@ -35,7 +35,7 @@ git_revision()
|
||||||
branch=".$(echo -n $branch | tr -sC '.[:alnum:]' '[.*]')"
|
branch=".$(echo -n $branch | tr -sC '.[:alnum:]' '[.*]')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ver" = "unknown" -o "$commits" ]; then
|
if [ "$untagged" -o "$commits" ]; then
|
||||||
sha=.g$(git log -1 --pretty="%h")
|
sha=.g$(git log -1 --pretty="%h")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -45,19 +45,19 @@ git_revision()
|
||||||
dirty=""
|
dirty=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ${ver}${commits}${branch}${sha}${dirty}
|
echo ${ver}${untagged}${commits}${branch}${sha}${dirty}
|
||||||
}
|
}
|
||||||
|
|
||||||
svn_revision()
|
svn_revision()
|
||||||
{
|
{
|
||||||
local ver tagrev commits rev dirty
|
local ver tagrev untagged commits rev dirty
|
||||||
|
|
||||||
ver=$1
|
ver=$1
|
||||||
|
|
||||||
tagrev=$(svn log -q ^/tags/release-$ver --limit 1 2> /dev/null | \
|
tagrev=$(svn log -q ^/tags/release-$ver --limit 1 2> /dev/null | \
|
||||||
awk '/^r/ {print $1}')
|
awk '/^r/ {print $1}')
|
||||||
if [ ! "$tagrev" ];then
|
if [ ! "$tagrev" ];then
|
||||||
ver="unknown"
|
untagged=".untagged"
|
||||||
else
|
else
|
||||||
commits=$(svn log -q -r $tagrev:HEAD | grep '^r' | wc -l)
|
commits=$(svn log -q -r $tagrev:HEAD | grep '^r' | wc -l)
|
||||||
if [ $commits -eq 0 ]; then
|
if [ $commits -eq 0 ]; then
|
||||||
|
@ -67,7 +67,7 @@ svn_revision()
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ver" = "unknown" -o "$commits" ]; then
|
if [ "$untagged" -o "$commits" ]; then
|
||||||
rev=.s$(svn info | awk '/^Revision:/ {print $2}')
|
rev=.s$(svn info | awk '/^Revision:/ {print $2}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ svn_revision()
|
||||||
dirty=".dirty"
|
dirty=".dirty"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ${ver}${commits}${rev}${dirty}
|
echo ${ver}${untagged}${commits}${rev}${dirty}
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -d .git || git rev-parse --git-dir > /dev/null 2>&1; then
|
if test -d .git || git rev-parse --git-dir > /dev/null 2>&1; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue