diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 975a223b..483c46ef 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -373,6 +373,8 @@ def try_init_submodules(app, last_build, vcs): vcs.initsubmodules() except NoSubmodulesException: logging.info("No submodules present for {}".format(_getappname(app))) + except VCSException: + logging.info("submodule broken for {}".format(_getappname(app))) # Return all directories under startdir that contain any of the manifest diff --git a/tests/run-tests b/tests/run-tests index 42374742..154b770e 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -65,11 +65,6 @@ fdroid_init_with_prebuilt_keystore() { echo 'keypass: r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI=' >> config.yml } -# 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` -} - is_MD5_disabled() { javac $WORKSPACE/tests/IsMD5Disabled.java && java -cp $WORKSPACE/tests IsMD5Disabled } @@ -141,6 +136,11 @@ else sed=sed fi +# allow the location of git to be overridden +if [ -z "$git" ]; then + git="env HOME= GIT_AUTHOR_NAME='Test' GIT_AUTHOR_EMAIL='no@mail' GIT_COMMITTER_NAME='Test' GIT_COMMITTER_EMAIL='no@mail' git" +fi + set -x # show each command as it is executed #------------------------------------------------------------------------------# @@ -1047,19 +1047,15 @@ fdroid_init_with_prebuilt_keystore cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/ echo "binary_transparency_remote: $GIT_REMOTE" >> config.yml $fdroid update --verbose -if have_git_2_3; then - $fdroid deploy --verbose - test -e repo/index.xml - test -e repo/index.jar - test -e repo/index-v1.jar - grep -F '> config.yml - cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/ - mkdir $OFFLINE_ROOT/unsigned - cp $WORKSPACE/tests/urzip-release-unsigned.apk $OFFLINE_ROOT/unsigned +cd $OFFLINE_ROOT +fdroid_init_with_prebuilt_keystore +printf '\narchive_older: 3\n' >> config.yml +cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/ +mkdir $OFFLINE_ROOT/unsigned +cp $WORKSPACE/tests/urzip-release-unsigned.apk $OFFLINE_ROOT/unsigned - echo "mirrors: ['http://foo.bar/fdroid', 'http://asdflkdsfjafdsdfhkjh.onion/fdroid']" >> config.yml - echo "servergitmirrors: $SERVER_GIT_MIRROR" >> config.yml - echo "local_copy_dir: $LOCAL_COPY_DIR" >> config.yml - $fdroid update --pretty - grep -F '' repo/index.xml - grep -F '/fdroid/archive' archive/index.xml - test `grep '' repo/index.xml | wc -l` -eq 2 - test `grep '' archive/index.xml | wc -l` -eq 2 - cd binary_transparency - [ `git rev-list --count HEAD` == "1" ] - cd .. - $fdroid deploy --verbose - test -e $LOCAL_COPY_DIR/unsigned/urzip-release-unsigned.apk - grep -F '> config.yml +echo "servergitmirrors: $SERVER_GIT_MIRROR" >> config.yml +echo "local_copy_dir: $LOCAL_COPY_DIR" >> config.yml +$fdroid update --pretty +grep -F '' repo/index.xml +grep -F '/fdroid/archive' archive/index.xml +test `grep '' repo/index.xml | wc -l` -eq 2 +test `grep '' archive/index.xml | wc -l` -eq 2 +cd binary_transparency +[ "$($git rev-list --count HEAD)" == "1" ] +cd .. +$fdroid deploy --verbose +test -e $LOCAL_COPY_DIR/unsigned/urzip-release-unsigned.apk +grep -F '> metadata/fake.yml - echo "CurrentVersion: 1" >> metadata/fake.yml - echo "CurrentVersionCode: 1" >> metadata/fake.yml +cd .. +mkdir repo +mkdir metadata +echo "RepoType: git" >> metadata/fake.yml +echo "Repo: file://$(pwd)/bar" >> metadata/fake.yml +echo "AutoUpdateMode: Version" >> metadata/fake.yml +echo "UpdateCheckMode: Tags" >> metadata/fake.yml +echo "UpdateCheckData: '|||'" >> metadata/fake.yml +echo "CurrentVersion: 1" >> metadata/fake.yml +echo "CurrentVersionCode: 1" >> metadata/fake.yml - $fdroid checkupdates --allow-dirty - grep "CurrentVersionCode: 2" metadata/fake.yml -fi +$fdroid checkupdates --allow-dirty +grep "CurrentVersionCode: 2" metadata/fake.yml + +#------------------------------------------------------------------------------# +echo_header "checkupdates ignore broken submodule" + +ROOT=$(create_test_dir) +cd "$ROOT" +mkdir foo bar +cd foo +$git init +echo a > a +$git add a +$git commit -m a + +cd ../bar +$git init +$git submodule add "file://$(pwd)/../foo" baz +$git commit -am a +$git tag 2 + +cd ../foo +# delete the commit referenced in bar +$git commit --amend -m aa +$git reflog expire --expire=now --all +$git gc --aggressive --prune=now + +cd .. +mkdir repo +mkdir metadata +echo "RepoType: git" >> metadata/fake.yml +echo "Repo: file://$(pwd)/bar" >> metadata/fake.yml +echo "Builds:" >> metadata/fake.yml +echo " - versionName: 1" >> metadata/fake.yml +echo " versionCode: 1" >> metadata/fake.yml +echo " submodules: true" >> metadata/fake.yml +echo "AutoUpdateMode: Version" >> metadata/fake.yml +echo "UpdateCheckMode: Tags" >> metadata/fake.yml +echo "UpdateCheckData: '|||'" >> metadata/fake.yml +echo "CurrentVersion: 1" >> metadata/fake.yml +echo "CurrentVersionCode: 1" >> metadata/fake.yml + +$fdroid checkupdates --allow-dirty +grep "CurrentVersionCode: 2" metadata/fake.yml #------------------------------------------------------------------------------#