Fix #3: ensure gitversion produces reliable versioning info across all branches
This commit is contained in:
@@ -10,7 +10,7 @@ fi
|
||||
|
||||
REBUILDING=0
|
||||
SHA1=$(git rev-parse HEAD)
|
||||
TAG=$(git describe --tags --abbrev=0 `git rev-list --tags --max-count=1 HEAD` 2>/dev/null)
|
||||
TAG=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||
BUILD=0
|
||||
TAGSHA=$(git rev-list $TAG | head -n 1)
|
||||
CHANGELOG="$(git log --format="format:$LOGSPEC" ${TAGSHA}..HEAD)"
|
||||
|
||||
61
tests/test_gitversion.sh
Normal file
61
tests/test_gitversion.sh
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(pwd)
|
||||
|
||||
function die
|
||||
{
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function shunittest_gitversion_use_correct_tag
|
||||
{
|
||||
tdir=$(mktemp -d)
|
||||
trap "rm -fr ${tdir}" EXIT
|
||||
cd ${tdir}
|
||||
git init .
|
||||
touch README
|
||||
git add README
|
||||
git commit -m 'test' README
|
||||
git tag -a -m 1.0-0 build,1.0,0
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
. version.sh
|
||||
[[ "$MAJOR" == "1.0" ]] || die "MAJOR should be 1.0, not $MAJOR"
|
||||
[[ "$BUILD" == "0" ]] || die "BUILD should be 0, not $BUILD"
|
||||
|
||||
git checkout -b branch1
|
||||
echo 'This is a meaningless change' > README
|
||||
git commit -m 'edited readme' README
|
||||
git tag -a -m 2.0dev-0 build,2.0dev,0
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
. version.sh
|
||||
[[ "$MAJOR" == "2.0dev" ]] || die "MAJOR should be 2.0dev, not $MAJOR"
|
||||
[[ "$BUILD" == "0" ]] || die "BUILD should be 0, not $BUILD"
|
||||
|
||||
git checkout master
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
. version.sh
|
||||
[[ "$MAJOR" == "1.0" ]] || die "MAJOR should be 1.0, not $MAJOR"
|
||||
[[ "$BUILD" == "0" ]] || die "BUILD should be 0, not $BUILD"
|
||||
}
|
||||
|
||||
function shunittest_gitversion_correct_rebuilding
|
||||
{
|
||||
tdir=$(mktemp -d)
|
||||
trap "rm -fr ${tdir}" EXIT
|
||||
cd ${tdir}
|
||||
git init .
|
||||
touch README
|
||||
git add README
|
||||
git commit -m 'test' README
|
||||
git tag -a -m 1.0-0 build,1.0,0
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
. version.sh
|
||||
[[ "$REBUILDING" == "0" ]] || die "REBUILDING should be 0, not $REBUILDING"
|
||||
echo 'small meaningless change' > README
|
||||
git commit -m 'test 2' README
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
. version.sh
|
||||
[[ "$REBUILDING" == "1" ]] || die "REBUILDING should be 1, not $REBUILDING"
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
function shunittest_shutup
|
||||
{
|
||||
return 0
|
||||
}
|
||||
39
tests/test_taggit.sh
Normal file
39
tests/test_taggit.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
BASEDIR=$(pwd)
|
||||
|
||||
function die
|
||||
{
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
function shunittest_test_environment_separator
|
||||
{
|
||||
tdir=$(mktemp -d)
|
||||
trap "rm -fr ${tdir}" EXIT
|
||||
cd ${tdir}
|
||||
git init .
|
||||
touch README
|
||||
git add README
|
||||
git commit -m 'test' README
|
||||
VERSIONERS_SEPARATOR='X' ${BASEDIR}/taggit.sh
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
tag=$(git describe --tags --abbrev=0)
|
||||
[[ "$tag" == "buildXmasterX0" ]] || die "Tag should be buildXmasterX0, got $tag"
|
||||
}
|
||||
|
||||
function shunittest_test_environment_tagbase
|
||||
{
|
||||
tdir=$(mktemp -d)
|
||||
trap "rm -fr ${tdir}" EXIT
|
||||
cd ${tdir}
|
||||
git init .
|
||||
touch README
|
||||
git add README
|
||||
git commit -m 'test' README
|
||||
VERSIONERS_TAGBASE='release' ${BASEDIR}/taggit.sh
|
||||
${BASEDIR}/gitversion.sh > version.sh
|
||||
tag=$(git describe --tags --abbrev=0)
|
||||
[[ "$tag" == "release,master,0" ]] || die "Tag should be release,master,0, got $tag"
|
||||
}
|
||||
Reference in New Issue
Block a user