upload: Add superproject identifier as push option
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>
This commit is contained in:
parent
1acbc14c34
commit
8d37f61471
2 changed files with 26 additions and 1 deletions
|
@ -28,6 +28,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
from git_command import git_require
|
from git_command import git_require
|
||||||
from git_command import GitCommand
|
from git_command import GitCommand
|
||||||
|
@ -140,6 +141,23 @@ class Superproject:
|
||||||
self._manifest_path if os.path.exists(self._manifest_path) else None
|
self._manifest_path if os.path.exists(self._manifest_path) else None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def repo_id(self):
|
||||||
|
"""Returns the repo ID for the superproject.
|
||||||
|
|
||||||
|
For example, if the superproject points to:
|
||||||
|
https://android-review.googlesource.com/platform/superproject/
|
||||||
|
Then the repo_id would be:
|
||||||
|
android/platform/superproject
|
||||||
|
"""
|
||||||
|
if review_url := self.remote.review:
|
||||||
|
parsed_url = urllib.parse.urlparse(review_url)
|
||||||
|
if netloc := parsed_url.netloc:
|
||||||
|
parts = netloc.split("-review", 1)
|
||||||
|
host = parts[0]
|
||||||
|
return f"{host}/{self.name}"
|
||||||
|
return None
|
||||||
|
|
||||||
def _LogMessage(self, fmt, *inputs):
|
def _LogMessage(self, fmt, *inputs):
|
||||||
"""Logs message to stderr and _git_event_log."""
|
"""Logs message to stderr and _git_event_log."""
|
||||||
message = f"{self._LogMessagePrefix()} {fmt.format(*inputs)}"
|
message = f"{self._LogMessagePrefix()} {fmt.format(*inputs)}"
|
||||||
|
|
|
@ -628,6 +628,13 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
||||||
branch.uploaded = False
|
branch.uploaded = False
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# If using superproject, add the root repo as a push option.
|
||||||
|
manifest = branch.project.manifest
|
||||||
|
push_options = list(opt.push_options)
|
||||||
|
sp = manifest.superproject
|
||||||
|
if sp and sp.repo_id and manifest.manifestProject.use_superproject:
|
||||||
|
push_options.append(f"custom-keyed-value=rootRepo:{sp.repo_id}")
|
||||||
|
|
||||||
branch.UploadForReview(
|
branch.UploadForReview(
|
||||||
people,
|
people,
|
||||||
dryrun=opt.dryrun,
|
dryrun=opt.dryrun,
|
||||||
|
@ -640,7 +647,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
||||||
ready=opt.ready,
|
ready=opt.ready,
|
||||||
dest_branch=destination,
|
dest_branch=destination,
|
||||||
validate_certs=opt.validate_certs,
|
validate_certs=opt.validate_certs,
|
||||||
push_options=opt.push_options,
|
push_options=push_options,
|
||||||
patchset_description=opt.patchset_description,
|
patchset_description=opt.patchset_description,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue