mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-10-15 01:47:08 +00:00
project: skip manifest default fallback for MetaProjects
Avoid loading manifest.xml during repo init when syncing a manifest commit SHA. Override _GetUpstreamFallback and _SharingProjectHasShallow in MetaProject to prevent premature manifest parsing. Bug: 544041102 Change-Id: I7aa54a7c1282e5bfe811d59e977b44163a37653c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/617081 Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Brian Gan <brgan@google.com>
This commit is contained in:
1 parent
d9da609d8c
commit
b85886fa9f
2 files changed
+109
-6
No files matched your search
+25
-6
@@ -2859,12 +2859,17 @@ class Project:
|
||||
|
||||
def _GetUpstreamFallback(self) -> Optional[str]:
|
||||
"""Resolve a fallback upstream ref when revisionExpr is a SHA-1."""
|
||||
for cand in (
|
||||
self.dest_branch,
|
||||
self.manifest.default.upstreamExpr,
|
||||
self.manifest.default.destBranchExpr,
|
||||
self.manifest.default.revisionExpr,
|
||||
):
|
||||
default = self.manifest.default
|
||||
candidates = [self.dest_branch]
|
||||
if default:
|
||||
candidates.extend(
|
||||
(
|
||||
default.upstreamExpr,
|
||||
default.destBranchExpr,
|
||||
default.revisionExpr,
|
||||
)
|
||||
)
|
||||
for cand in candidates:
|
||||
if cand and not IsId(cand):
|
||||
return cand
|
||||
return None
|
||||
@@ -4737,6 +4742,20 @@ class MetaProject(Project):
|
||||
# before manifest.xml has been linked into .repo/.
|
||||
return False
|
||||
|
||||
def _GetUpstreamFallback(self) -> Optional[str]:
|
||||
# MetaProjects (the manifest repo and repo itself) do not have
|
||||
# defaults in a manifest. Returning None here also avoids
|
||||
# loading the manifest during `repo init`, before manifest.xml
|
||||
# has been linked into .repo/.
|
||||
return None
|
||||
|
||||
def _SharingProjectHasShallow(self) -> bool:
|
||||
# MetaProjects (the manifest repo and repo itself) are never
|
||||
# shared with other projects in the manifest. Returning False
|
||||
# here also avoids loading the manifest during `repo init`,
|
||||
# before manifest.xml has been linked into .repo/.
|
||||
return False
|
||||
|
||||
@property
|
||||
def HasChanges(self):
|
||||
"""Has the remote received new commits not yet checked out?"""
|
||||
|
||||
Reference in new issue
Block a user