From: Ferry Huberts <[email protected]> To ensure the versions are in sync
Signed-off-by: Ferry Huberts <[email protected]> --- tests/t0001-validate-git-versions.sh | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 tests/t0001-validate-git-versions.sh diff --git a/tests/t0001-validate-git-versions.sh b/tests/t0001-validate-git-versions.sh new file mode 100755 index 0000000..22066c0 --- /dev/null +++ b/tests/t0001-validate-git-versions.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +. ./setup.sh + + +test_versions() +{ + curdir=`pwd` + cd .. + + gitSubmoduleStatus=`git submodule status git` + echo "gitSubmoduleStatus = $gitSubmoduleStatus" + + gitSubmoduleStatusFirstChar=`echo "$gitSubmoduleStatus" | cut -c -1` + echo "gitSubmoduleStatusFirstChar = $gitSubmoduleStatusFirstChar" + + # Fail the test if the Git submodule is not initialised + test "$gitSubmoduleStatusFirstChar" == "-" && \ + echo "The Git submodule is not initialised" && \ + return 1 + + # Fail the test if the Git submodule is not clean + test "$gitSubmoduleStatusFirstChar" != " " && \ + echo "The Git submodule is not clean" && \ + return 1 + + # Get the SHA1 from the (clean) Git submodule + gitSubmoduleVersionSha=`git submodule status git| awk '{ print $1 }' | cut -c 1-` + echo "gitSubmoduleVersionSha = $gitSubmoduleVersionSha" + + # Extract the Git version of the archive from the Makefile + regex='^[[:space:]]*GIT_VER[[:space:]]*=[[:space:]]*(.*)[[:space:]]*$' + archiveVersion=`grep -E "$regex" Makefile | sed -r "s/$regex/\1/"` + echo "archiveVersion = $archiveVersion" + + # Compare the Git submodule version and the Makefile Git version + cd git + git diff --exit-code --quiet "$gitSubmoduleVersionSha..v$archiveVersion" + diffExitCode=$? + echo "diffExitCode = $diffExitCode" + cd .. + + # Return to the original directory + cd "$curdir" + + # Determine exit code + test $diffExitCode -ne 0 && return 1 + return 0 +} + + +prepare_tests 'Check Git version consistency' + +git=`which git` +test -n "$git" || { + echo "Skipping test: git not found" + tests_done + exit +} + +run_test 'test versions' 'test_versions' + +tests_done -- 1.7.11.7 _______________________________________________ cgit mailing list [email protected] http://hjemli.net/mailman/listinfo/cgit
