diff options
-rw-r--r-- | command.py | 4 | ||||
-rw-r--r-- | git_superproject.py | 2 | ||||
-rw-r--r-- | gitc_utils.py | 20 | ||||
-rw-r--r-- | manifest_xml.py | 12 | ||||
-rw-r--r-- | subcmds/init.py | 2 | ||||
-rw-r--r-- | tests/test_git_superproject.py | 12 | ||||
-rw-r--r-- | tests/test_manifest_xml.py | 6 |
7 files changed, 31 insertions, 27 deletions
@@ -178,9 +178,7 @@ class Command(object): | |||
178 | mp = manifest.manifestProject | 178 | mp = manifest.manifestProject |
179 | 179 | ||
180 | if not groups: | 180 | if not groups: |
181 | groups = mp.config.GetString('manifest.groups') | 181 | groups = manifest.GetGroupsStr() |
182 | if not groups: | ||
183 | groups = 'default,platform-' + platform.system().lower() | ||
184 | groups = [x for x in re.split(r'[,\s]+', groups) if x] | 182 | groups = [x for x in re.split(r'[,\s]+', groups) if x] |
185 | 183 | ||
186 | if not args: | 184 | if not args: |
diff --git a/git_superproject.py b/git_superproject.py index 651da48a..7f0582cb 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
@@ -235,7 +235,7 @@ class Superproject(object): | |||
235 | self._superproject_path, | 235 | self._superproject_path, |
236 | file=sys.stderr) | 236 | file=sys.stderr) |
237 | return None | 237 | return None |
238 | manifest_str = self._manifest.ToXml().toxml() | 238 | manifest_str = self._manifest.ToXml(groups=self._manifest.GetGroupsStr()).toxml() |
239 | manifest_path = self._manifest_path | 239 | manifest_path = self._manifest_path |
240 | try: | 240 | try: |
241 | with open(manifest_path, 'w', encoding='utf-8') as fp: | 241 | with open(manifest_path, 'w', encoding='utf-8') as fp: |
diff --git a/gitc_utils.py b/gitc_utils.py index a2786c9f..486bbeb0 100644 --- a/gitc_utils.py +++ b/gitc_utils.py | |||
@@ -77,22 +77,6 @@ def _set_project_revisions(projects): | |||
77 | project.revisionExpr = revisionExpr | 77 | project.revisionExpr = revisionExpr |
78 | 78 | ||
79 | 79 | ||
80 | def _manifest_groups(manifest): | ||
81 | """Returns the manifest group string that should be synced | ||
82 | |||
83 | This is the same logic used by Command.GetProjects(), which is used during | ||
84 | repo sync | ||
85 | |||
86 | Args: | ||
87 | manifest: The XmlManifest object | ||
88 | """ | ||
89 | mp = manifest.manifestProject | ||
90 | groups = mp.config.GetString('manifest.groups') | ||
91 | if not groups: | ||
92 | groups = 'default,platform-' + platform.system().lower() | ||
93 | return groups | ||
94 | |||
95 | |||
96 | def generate_gitc_manifest(gitc_manifest, manifest, paths=None): | 80 | def generate_gitc_manifest(gitc_manifest, manifest, paths=None): |
97 | """Generate a manifest for shafsd to use for this GITC client. | 81 | """Generate a manifest for shafsd to use for this GITC client. |
98 | 82 | ||
@@ -107,7 +91,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None): | |||
107 | if paths is None: | 91 | if paths is None: |
108 | paths = list(manifest.paths.keys()) | 92 | paths = list(manifest.paths.keys()) |
109 | 93 | ||
110 | groups = [x for x in re.split(r'[,\s]+', _manifest_groups(manifest)) if x] | 94 | groups = [x for x in re.split(r'[,\s]+', manifest.GetGroupsStr()) if x] |
111 | 95 | ||
112 | # Convert the paths to projects, and filter them to the matched groups. | 96 | # Convert the paths to projects, and filter them to the matched groups. |
113 | projects = [manifest.paths[p] for p in paths] | 97 | projects = [manifest.paths[p] for p in paths] |
@@ -166,7 +150,7 @@ def save_manifest(manifest, client_dir=None): | |||
166 | else: | 150 | else: |
167 | manifest_file = os.path.join(client_dir, '.manifest') | 151 | manifest_file = os.path.join(client_dir, '.manifest') |
168 | with open(manifest_file, 'w') as f: | 152 | with open(manifest_file, 'w') as f: |
169 | manifest.Save(f, groups=_manifest_groups(manifest)) | 153 | manifest.Save(f, groups=manifest.GetGroupsStr()) |
170 | # TODO(sbasi/jorg): Come up with a solution to remove the sleep below. | 154 | # TODO(sbasi/jorg): Come up with a solution to remove the sleep below. |
171 | # Give the GITC filesystem time to register the manifest changes. | 155 | # Give the GITC filesystem time to register the manifest changes. |
172 | time.sleep(3) | 156 | time.sleep(3) |
diff --git a/manifest_xml.py b/manifest_xml.py index e96e0620..6d8fca1d 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | import itertools | 15 | import itertools |
16 | import os | 16 | import os |
17 | import platform | ||
17 | import re | 18 | import re |
18 | import sys | 19 | import sys |
19 | import xml.dom.minidom | 20 | import xml.dom.minidom |
@@ -604,6 +605,17 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
604 | def HasSubmodules(self): | 605 | def HasSubmodules(self): |
605 | return self.manifestProject.config.GetBoolean('repo.submodules') | 606 | return self.manifestProject.config.GetBoolean('repo.submodules') |
606 | 607 | ||
608 | def GetDefaultGroupsStr(self): | ||
609 | """Returns the default group string for the platform.""" | ||
610 | return 'default,platform-' + platform.system().lower() | ||
611 | |||
612 | def GetGroupsStr(self): | ||
613 | """Returns the manifest group string that should be synced.""" | ||
614 | groups = self.manifestProject.config.GetString('manifest.groups') | ||
615 | if not groups: | ||
616 | groups = self.GetDefaultGroupsStr() | ||
617 | return groups | ||
618 | |||
607 | def _Unload(self): | 619 | def _Unload(self): |
608 | self._loaded = False | 620 | self._loaded = False |
609 | self._projects = {} | 621 | self._projects = {} |
diff --git a/subcmds/init.py b/subcmds/init.py index 471efc1e..86b77742 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -267,7 +267,7 @@ to update the working directory files. | |||
267 | 267 | ||
268 | groups = [x for x in groups if x] | 268 | groups = [x for x in groups if x] |
269 | groupstr = ','.join(groups) | 269 | groupstr = ','.join(groups) |
270 | if opt.platform == 'auto' and groupstr == 'default,platform-' + platform.system().lower(): | 270 | if opt.platform == 'auto' and groupstr == self.manifest.GetDefaultGroupsStr(): |
271 | groupstr = None | 271 | groupstr = None |
272 | m.config.SetString('manifest.groups', groupstr) | 272 | m.config.SetString('manifest.groups', groupstr) |
273 | 273 | ||
diff --git a/tests/test_git_superproject.py b/tests/test_git_superproject.py index 07b9a7db..9550949b 100644 --- a/tests/test_git_superproject.py +++ b/tests/test_git_superproject.py | |||
@@ -15,6 +15,7 @@ | |||
15 | """Unittests for the git_superproject.py module.""" | 15 | """Unittests for the git_superproject.py module.""" |
16 | 16 | ||
17 | import os | 17 | import os |
18 | import platform | ||
18 | import tempfile | 19 | import tempfile |
19 | import unittest | 20 | import unittest |
20 | from unittest import mock | 21 | from unittest import mock |
@@ -34,6 +35,7 @@ class SuperprojectTestCase(unittest.TestCase): | |||
34 | self.manifest_file = os.path.join( | 35 | self.manifest_file = os.path.join( |
35 | self.repodir, manifest_xml.MANIFEST_FILE_NAME) | 36 | self.repodir, manifest_xml.MANIFEST_FILE_NAME) |
36 | os.mkdir(self.repodir) | 37 | os.mkdir(self.repodir) |
38 | self.platform = platform.system().lower() | ||
37 | 39 | ||
38 | # The manifest parsing really wants a git repo currently. | 40 | # The manifest parsing really wants a git repo currently. |
39 | gitdir = os.path.join(self.repodir, 'manifests.git') | 41 | gitdir = os.path.join(self.repodir, 'manifests.git') |
@@ -48,8 +50,8 @@ class SuperprojectTestCase(unittest.TestCase): | |||
48 | <remote name="default-remote" fetch="http://localhost" /> | 50 | <remote name="default-remote" fetch="http://localhost" /> |
49 | <default remote="default-remote" revision="refs/heads/main" /> | 51 | <default remote="default-remote" revision="refs/heads/main" /> |
50 | <superproject name="superproject"/> | 52 | <superproject name="superproject"/> |
51 | <project path="art" name="platform/art" /> | 53 | <project path="art" name="platform/art" groups="notdefault,platform-""" + self.platform + """ |
52 | </manifest> | 54 | " /></manifest> |
53 | """) | 55 | """) |
54 | self._superproject = git_superproject.Superproject(manifest, self.repodir) | 56 | self._superproject = git_superproject.Superproject(manifest, self.repodir) |
55 | 57 | ||
@@ -142,7 +144,8 @@ class SuperprojectTestCase(unittest.TestCase): | |||
142 | '<?xml version="1.0" ?><manifest>' + | 144 | '<?xml version="1.0" ?><manifest>' + |
143 | '<remote name="default-remote" fetch="http://localhost"/>' + | 145 | '<remote name="default-remote" fetch="http://localhost"/>' + |
144 | '<default remote="default-remote" revision="refs/heads/main"/>' + | 146 | '<default remote="default-remote" revision="refs/heads/main"/>' + |
145 | '<project name="platform/art" path="art" revision="ABCDEF"/>' + | 147 | '<project name="platform/art" path="art" revision="ABCDEF" ' + |
148 | 'groups="notdefault,platform-' + self.platform + '"/>' + | ||
146 | '<superproject name="superproject"/>' + | 149 | '<superproject name="superproject"/>' + |
147 | '</manifest>') | 150 | '</manifest>') |
148 | 151 | ||
@@ -169,7 +172,8 @@ class SuperprojectTestCase(unittest.TestCase): | |||
169 | '<remote name="default-remote" fetch="http://localhost"/>' + | 172 | '<remote name="default-remote" fetch="http://localhost"/>' + |
170 | '<default remote="default-remote" revision="refs/heads/main"/>' + | 173 | '<default remote="default-remote" revision="refs/heads/main"/>' + |
171 | '<project name="platform/art" path="art" ' + | 174 | '<project name="platform/art" path="art" ' + |
172 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea"/>' + | 175 | 'revision="2c2724cb36cd5a9cec6c852c681efc3b7c6b86ea" ' + |
176 | 'groups="notdefault,platform-' + self.platform + '"/>' + | ||
173 | '<superproject name="superproject"/>' + | 177 | '<superproject name="superproject"/>' + |
174 | '</manifest>') | 178 | '</manifest>') |
175 | 179 | ||
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index 6977b417..9060ef3d 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py | |||
@@ -15,6 +15,7 @@ | |||
15 | """Unittests for the manifest_xml.py module.""" | 15 | """Unittests for the manifest_xml.py module.""" |
16 | 16 | ||
17 | import os | 17 | import os |
18 | import platform | ||
18 | import shutil | 19 | import shutil |
19 | import tempfile | 20 | import tempfile |
20 | import unittest | 21 | import unittest |
@@ -377,6 +378,11 @@ class ProjectElementTests(ManifestParseTestCase): | |||
377 | self.assertCountEqual( | 378 | self.assertCountEqual( |
378 | result['extras'], | 379 | result['extras'], |
379 | ['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path']) | 380 | ['g1', 'g2', 'g1', 'name:extras', 'all', 'path:path']) |
381 | groupstr = 'default,platform-' + platform.system().lower() | ||
382 | self.assertEqual(groupstr, manifest.GetGroupsStr()) | ||
383 | groupstr = 'g1,g2,g1' | ||
384 | manifest.manifestProject.config.SetString('manifest.groups', groupstr) | ||
385 | self.assertEqual(groupstr, manifest.GetGroupsStr()) | ||
380 | 386 | ||
381 | def test_set_revision_id(self): | 387 | def test_set_revision_id(self): |
382 | """Check setting of project's revisionId.""" | 388 | """Check setting of project's revisionId.""" |