diff --git a/git_superproject.py b/git_superproject.py index 5d00bd72..8b6bbcf9 100644 --- a/git_superproject.py +++ b/git_superproject.py @@ -295,7 +295,8 @@ class Superproject(object): if not os.path.exists(self._superproject_path): self._LogWarning(f'missing superproject directory: {self._superproject_path}') return None - manifest_str = self._manifest.ToXml(groups=self._manifest.GetGroupsStr()).toxml() + manifest_str = self._manifest.ToXml(groups=self._manifest.GetGroupsStr(), + omit_local=True).toxml() manifest_path = self._manifest_path try: with open(manifest_path, 'w', encoding='utf-8') as fp: diff --git a/manifest_xml.py b/manifest_xml.py index 32f6b687..12614c64 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -502,7 +502,8 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md """ return [x for x in re.split(r'[,\s]+', field) if x] - def ToXml(self, peg_rev=False, peg_rev_upstream=True, peg_rev_dest_branch=True, groups=None): + def ToXml(self, peg_rev=False, peg_rev_upstream=True, + peg_rev_dest_branch=True, groups=None, omit_local=False): """Return the current manifest XML.""" mp = self.manifestProject @@ -583,6 +584,9 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md if not p.MatchesGroups(groups): return + if omit_local and self.IsFromLocalManifest(p): + return + name = p.name relpath = p.relpath if parent: diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index 603694d2..0ad9b01d 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py @@ -312,9 +312,6 @@ class SuperprojectTestCase(unittest.TestCase): '' - '' '' '') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 85c20733..48403c0d 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -252,6 +252,37 @@ class XmlManifestTests(ManifestParseTestCase): '') self.assertEqual(manifest.ToDict(), {}) + def test_toxml_omit_local(self): + """Does not include local_manifests projects when omit_local=True.""" + manifest = self.getXmlManifest( + '' + '' + '' + '' + '' + '') + self.assertEqual( + manifest.ToXml(omit_local=True).toxml(), + '' + '' + '') + + def test_toxml_with_local(self): + """Does include local_manifests projects when omit_local=False.""" + manifest = self.getXmlManifest( + '' + '' + '' + '' + '' + '') + self.assertEqual( + manifest.ToXml(omit_local=False).toxml(), + '' + '' + '' + '') + def test_repo_hooks(self): """Check repo-hooks settings.""" manifest = self.getXmlManifest("""