chiark / gitweb /
git mirror test requires git >= 2.3
authorHans-Christoph Steiner <hans@eds.org>
Wed, 12 Apr 2017 13:26:51 +0000 (15:26 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Wed, 12 Apr 2017 22:49:36 +0000 (00:49 +0200)
tests/run-tests

index ac3665a79f2644d4a6d518e87ae8f53972bd4088..563145a5b9076f33d45d7917bbd68cf058039fa8 100755 (executable)
@@ -41,6 +41,11 @@ create_test_file() {
     TMPDIR=$WORKSPACE/.testfiles  mktemp
 }
 
+# the < is reverse since 0 means success in exit codes
+have_git_2_3() {
+    python3 -c "import sys; from distutils.version import LooseVersion as V; sys.exit(V(sys.argv[3]) < V('2.3'))" `git --version`
+}
+
 #------------------------------------------------------------------------------#
 # "main"
 
@@ -602,15 +607,19 @@ echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
 echo "binary_transparency_remote = '$GIT_REMOTE'" >> config.py
 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
 $fdroid update --verbose
-$fdroid server update --verbose
-test -e repo/index.xml
-test -e repo/index.jar
-test -e repo/index-v1.jar
-grep -F '<application id=' repo/index.xml > /dev/null
-cd binary_transparency
-[ `git rev-list --count HEAD` == "2" ]
-cd $GIT_REMOTE
-[ `git rev-list --count HEAD` == "2" ]
+if have_git_2_3; then
+    $fdroid server update --verbose
+    test -e repo/index.xml
+    test -e repo/index.jar
+    test -e repo/index-v1.jar
+    grep -F '<application id=' repo/index.xml > /dev/null
+    cd binary_transparency
+    [ `git rev-list --count HEAD` == "2" ]
+    cd $GIT_REMOTE
+    [ `git rev-list --count HEAD` == "2" ]
+else
+    echo "Skipping test, `git --version` older than 2.3"
+fi
 
 
 #------------------------------------------------------------------------------#
@@ -683,7 +692,9 @@ BINARY_TRANSPARENCY_REMOTE=`create_test_dir`
 SERVER_GIT_MIRROR=`create_test_dir`
 cd $SERVER_GIT_MIRROR
 git init
-git config receive.denyCurrentBranch updateInstead
+if have_git_2_3; then
+    git config receive.denyCurrentBranch updateInstead
+fi
 
 cd $OFFLINE_ROOT
 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
@@ -699,20 +710,24 @@ grep -F '<application id=' repo/index.xml > /dev/null
 cd binary_transparency
 [ `git rev-list --count HEAD` == "1" ]
 cd ..
-$fdroid server update --verbose
-grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
-cd $ONLINE_ROOT
-echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
-echo "sync_from_local_copy_dir = True" >> config.py
-echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
-echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
-echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
-echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
-$fdroid server update --verbose
-cd $BINARY_TRANSPARENCY_REMOTE
-[ `git rev-list --count HEAD` == "1" ]
-cd $SERVER_GIT_MIRROR
-[ `git rev-list --count HEAD` == "1" ]
+if have_git_2_3; then
+    $fdroid server update --verbose
+    grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
+    cd $ONLINE_ROOT
+    echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
+    echo "sync_from_local_copy_dir = True" >> config.py
+    echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
+    echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
+    echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
+    echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
+    $fdroid server update --verbose
+    cd $BINARY_TRANSPARENCY_REMOTE
+    [ `git rev-list --count HEAD` == "1" ]
+    cd $SERVER_GIT_MIRROR
+    [ `git rev-list --count HEAD` == "1" ]
+else
+    echo "Skipping test, `git --version` older than 2.3"
+fi
 
 
 #------------------------------------------------------------------------------#