diff options
author | Raman Tenneti <rtenneti@google.com> | 2021-03-09 15:19:06 -0800 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2021-03-11 01:24:52 +0000 |
commit | 080877e41347b8987977fc8cc3ec90dcd149651a (patch) | |
tree | 57a8c76bd02da5f9400cdec5da6a75f4e4f2d3f2 /gitc_utils.py | |
parent | 9888accb0cf2c17e0f4bbc399782ccd2a4be0196 (diff) | |
download | git-repo-080877e41347b8987977fc8cc3ec90dcd149651a.tar.gz |
superproject: pass groups to ToXml method.
Added the following methods to XmlManifest class.
+ GetDefaultGroupsStr() - return 'default,platform-' + platform.system().lower()
+ GetGroupsStr() - Same as gitc_utils.py's _manifest_groups func.
+ Replaced gitc_utils.py's_manifest_groups calls with GetGroupsStr.
+ Used the above methods to get groups in command.py::GetProjects
and part of init.py.
TODO: clean up these funcs to take structured group data more instead
of passing strings around everywhere that need parsing.
Tested the code with the following commands.
$ ./run_tests -v
Tested the sync code by using repo_dev alias and pointing to this CL
and verified prebuilts/fullsdk-linux directory has all the folders.
Tested repo init and repo sync with --use-superproject and without
--use-superproject argument.
$ repo_dev init -u sso://android.git.corp.google.com/platform/manifest -b androidx-main --partial-clone --clone-filter=blob:limit=10M --repo-rev=main --use-superproject
$ repo_dev sync -c -j32
Bug: [google internal] b/181804931
Bug: https://crbug.com/gerrit/13707
Change-Id: Ia98585cbfa3a1449710655af55d56241794242b6
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299422
Reviewed-by: Jonathan Nieder <jrn@google.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Raman Tenneti <rtenneti@google.com>
Diffstat (limited to 'gitc_utils.py')
-rw-r--r-- | gitc_utils.py | 20 |
1 files changed, 2 insertions, 18 deletions
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) |