John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 3 | test_description='Check Git version is correct' |
| 4 | CGIT_TEST_NO_CREATE_REPOS=YesPlease |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 5 | . ./setup.sh |
| 6 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 7 | test_expect_success 'extract Git version from Makefile' ' |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 8 | sed -n -e "/^GIT_VER[ ]*=/ { |
| 9 | s/^GIT_VER[ ]*=[ ]*// |
| 10 | p |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 11 | }" ../../Makefile >makefile_version |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 12 | ' |
| 13 | |
John Keeping | 8d07ad3 | 2013-04-27 10:48:56 +0100 | [diff] [blame] | 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. |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 18 | test_expect_success 'test Git version matches Makefile' ' |
| 19 | ( cat ../../git/GIT-VERSION-FILE || echo "No GIT-VERSION-FILE" ) | |
John Keeping | d483e8f | 2013-04-14 19:15:43 +0100 | [diff] [blame] | 20 | sed -e "s/GIT_VERSION[ ]*=[ ]*//" -e "s/\\.dirty$//" >git_version && |
John Keeping | 8d07ad3 | 2013-04-27 10:48:56 +0100 | [diff] [blame] | 21 | sed -e "s/-/./g" makefile_version >makefile_git_version && |
| 22 | test_cmp git_version makefile_git_version |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 23 | ' |
| 24 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 25 | test_expect_success 'test submodule version matches Makefile' ' |
| 26 | if ! test -e ../../git/.git |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 27 | then |
| 28 | echo "git/ is not a Git repository" >&2 |
| 29 | else |
| 30 | ( |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 31 | cd ../.. && |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 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 |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 36 | ) | sed -e "s/^v//" >sm_version && |
| 37 | test_cmp sm_version makefile_version |
John Keeping | e1e0e03 | 2013-03-19 20:00:29 +0000 | [diff] [blame] | 38 | fi |
| 39 | ' |
| 40 | |
John Keeping | c95cc5e | 2013-04-01 15:09:05 +0100 | [diff] [blame] | 41 | test_done |