Ignore git submodule failure in gotorevisionx

gotorevisionx tries to clean up the git repo before checking out a new
revision. In b848b99ba this was changed to reset and clean any submodule
as well. In case upstream has a broken submodule configuration this
could fail and we can't checkout the new revision. As we are doing a
reset and clean after checking out the new revision anyhow, this change
ignores submodule errors before the checkout and only makes sure that
the main repo is reset and clean.

This broke checkupdates for apps where old versions had broken
submodules. It checkout out the old version and got stuck, not able to
checkout any other version.
This commit is contained in:
Jochen Sprickerhof 2021-06-12 09:09:55 +02:00
parent 02a63a2ec0
commit 3809b4d424
2 changed files with 44 additions and 0 deletions

View File

@ -1103,12 +1103,18 @@ class vcs_git(vcs):
# Discard any working tree changes
p = FDroidPopen(['git', 'submodule', 'foreach', '--recursive',
'git', 'reset', '--hard'], cwd=self.local, output=False)
if p.returncode != 0:
logging.debug("Git submodule reset failed (ignored) {output}".format(output=p.output))
p = FDroidPopen(['git', 'reset', '--hard'], cwd=self.local, output=False)
if p.returncode != 0:
raise VCSException(_("Git reset failed"), p.output)
# Remove untracked files now, in case they're tracked in the target
# revision (it happens!)
p = FDroidPopen(['git', 'submodule', 'foreach', '--recursive',
'git', 'clean', '-dffx'], cwd=self.local, output=False)
if p.returncode != 0:
logging.debug("Git submodule cleanup failed (ignored) {output}".format(output=p.output))
p = FDroidPopen(['git', 'clean', '-dffx'], cwd=self.local, output=False)
if p.returncode != 0:
raise VCSException(_("Git clean failed"), p.output)
if not self.refreshed:

View File

@ -1295,6 +1295,44 @@ else
echo "WARNING: wget not installed, skipping"
fi
#------------------------------------------------------------------------------#
echo_header "Test recovering from from broken git submodules"
if have_git_2_3; then
ROOT=$(create_test_dir)
cd "$ROOT"
mkdir foo bar
cd foo
git init
echo a > a
git add a
GIT_COMMITTER_NAME="Test" GIT_COMMITTER_EMAIL="no@mail" git commit -m "a" --author "Author <no@mail>"
cd ../bar
git init
git submodule add "file://$(pwd)/../foo" baz
rm .gitmodules
GIT_COMMITTER_NAME="Test" GIT_COMMITTER_EMAIL="no@mail" git commit -am "a" --author "Author <no@mail>"
rm -rf baz
git checkout baz
git tag 2
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
#------------------------------------------------------------------------------#
# remove this to prevent git conflicts and complaining