diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 06284898..087dd431 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -1174,6 +1174,10 @@ class vcs: def initsubmodules(self): raise VCSException('Submodules not supported for this vcs type') + # Deinitialise and update submodules + def deinitsubmodules(self): + pass + # Get a list of all known tags def gettags(self): if not self._gettags: @@ -1338,6 +1342,12 @@ class vcs_git(vcs): if p.returncode != 0: raise VCSException(_("Git submodule update failed"), p.output) + def deinitsubmodules(self): + self.checkrepo() + p = FDroidPopen(['git', 'submodule', 'deinit', '--all'], cwd=self.local, output=False) + if p.returncode != 0: + raise VCSException(_("Git submodule deinit failed"), p.output) + def _gettags(self): self.checkrepo() p = FDroidPopen(['git', 'tag'], cwd=self.local, output=False) @@ -2188,6 +2198,8 @@ def prepare_source(vcs, app, build, build_dir, srclib_dir, extlib_dir, onserver= if build.submodules: logging.info(_("Initialising submodules")) vcs.initsubmodules() + else: + vcs.deinitsubmodules() # Check that a subdir (if we're using one) exists. This has to happen # after the checkout, since it might not exist elsewhere diff --git a/tests/build.TestCase b/tests/build.TestCase index 4a4c0001..cce6a424 100755 --- a/tests/build.TestCase +++ b/tests/build.TestCase @@ -586,6 +586,9 @@ class BuildTest(unittest.TestCase): def getsrclib(self): return None + def deinitsubmodules(self): + pass + # Test we trigger a scanner error without extlibs build.extlibs = [] os.makedirs('build/libs') diff --git a/tests/common.TestCase b/tests/common.TestCase index 26cd979c..0fc8c41f 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -315,6 +315,9 @@ class CommonTest(unittest.TestCase): def getsrclib(self): return None + def deinitsubmodules(self): + pass + fdroidserver.common.prepare_source(FakeVcs(), app, build, fdroidclient_testdir, fdroidclient_testdir, fdroidclient_testdir) @@ -385,6 +388,9 @@ class CommonTest(unittest.TestCase): def getsrclib(self): return None + def deinitsubmodules(self): + pass + fdroidserver.common.prepare_source(FakeVcs(), app, build, app_build_dir, srclib_testdir, app_build_dir, onserver=True, refresh=False) # do not clone in this test