tests/t0001-validate-git-versions.sh (view raw)
1#!/bin/sh
2
3test_description='Check Git version is correct'
4CGIT_TEST_NO_CREATE_REPOS=YesPlease
5. ./setup.sh
6
7test_expect_success 'extract Git version from Makefile' '
8 sed -n -e "/^GIT_VER[ ]*=/ {
9 s/^GIT_VER[ ]*=[ ]*//
10 p
11 }" ../../Makefile >makefile_version
12'
13
14# Note that Git's GIT-VERSION-GEN script applies "s/-/./g" to the version
15# string to produce the internal version in the GIT-VERSION-FILE, so we
16# must apply the same transformation to the version in the Makefile before
17# comparing them.
18test_expect_success 'test Git version matches Makefile' '
19 ( cat ../../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) |
20 sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version &&
21 sed -e "s/-/./g" makefile_version >makefile_git_version &&
22 test_cmp git_version makefile_git_version
23'
24
25test_expect_success 'test submodule version matches Makefile' '
26 if ! test -e ../../git/.git
27 then
28 echo "git/ is not a Git repository" >&2
29 else
30 (
31 cd ../.. &&
32 sm_sha1=$(git ls-files --stage -- git |
33 sed -e "s/^[0-9]* \\([0-9a-f]*\\) [0-9] .*$/\\1/") &&
34 cd git &&
35 git describe --match "v[0-9]*" $sm_sha1
36 ) | sed -e "s/^v//" >sm_version &&
37 test_cmp sm_version makefile_version
38 fi
39'
40
41test_done