diff options
author | Gavin Mak <gavinmak@google.com> | 2025-05-05 14:13:48 -0700 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2025-05-05 15:10:49 -0700 |
commit | 8d37f6147174fe170cc00a1d82b1cc5fe8ec0a7b (patch) | |
tree | ed1f7413c2e9093243b7f4d83377e2a72d47742e /git_superproject.py | |
parent | 1acbc14c34f264e0158436dc3d0265d500848462 (diff) | |
download | git-repo-main.tar.gz |
upload: Add superproject identifier as push optionmain
When uploading, add the root superproject repo as a push option in the
format `-o custom-keyed-value=rootRepo:$HOST/$PROJECT`.
Bug: b/401147338
Change-Id: I00230256eb7ae307b03840bb4090c28dc8a0505e
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/472601
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Tested-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Diffstat (limited to 'git_superproject.py')
-rw-r--r-- | git_superproject.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/git_superproject.py b/git_superproject.py index ce8161fd..aba836a3 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
@@ -28,6 +28,7 @@ import os | |||
28 | import sys | 28 | import sys |
29 | import time | 29 | import time |
30 | from typing import NamedTuple | 30 | from typing import NamedTuple |
31 | import urllib.parse | ||
31 | 32 | ||
32 | from git_command import git_require | 33 | from git_command import git_require |
33 | from git_command import GitCommand | 34 | from git_command import GitCommand |
@@ -140,6 +141,23 @@ class Superproject: | |||
140 | self._manifest_path if os.path.exists(self._manifest_path) else None | 141 | self._manifest_path if os.path.exists(self._manifest_path) else None |
141 | ) | 142 | ) |
142 | 143 | ||
144 | @property | ||
145 | def repo_id(self): | ||
146 | """Returns the repo ID for the superproject. | ||
147 | |||
148 | For example, if the superproject points to: | ||
149 | https://android-review.googlesource.com/platform/superproject/ | ||
150 | Then the repo_id would be: | ||
151 | android/platform/superproject | ||
152 | """ | ||
153 | if review_url := self.remote.review: | ||
154 | parsed_url = urllib.parse.urlparse(review_url) | ||
155 | if netloc := parsed_url.netloc: | ||
156 | parts = netloc.split("-review", 1) | ||
157 | host = parts[0] | ||
158 | return f"{host}/{self.name}" | ||
159 | return None | ||
160 | |||
143 | def _LogMessage(self, fmt, *inputs): | 161 | def _LogMessage(self, fmt, *inputs): |
144 | """Logs message to stderr and _git_event_log.""" | 162 | """Logs message to stderr and _git_event_log.""" |
145 | message = f"{self._LogMessagePrefix()} {fmt.format(*inputs)}" | 163 | message = f"{self._LogMessagePrefix()} {fmt.format(*inputs)}" |