summaryrefslogtreecommitdiffstats
path: root/git_superproject.py
diff options
context:
space:
mode:
authorGavin Mak <gavinmak@google.com>2026-04-22 00:39:42 +0000
committergerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-05-20 12:28:55 -0700
commit2d54384a5e59fddd0626ec091cc0ad11511d834e (patch)
treec0a9d642bb4064a23df2044777b6f81f2c047473 /git_superproject.py
parent1b4e7a04be7b49d8c0c5e161d36f209bca4b6498 (diff)
downloadgit-repo-2.64.tar.gz
sync: Add --superproject-rev flag to sync to specific revisionv2.64
Allow syncing the outer manifest to a state defined by a specific superproject revision. It updates the superproject, reads the manifest commit from .supermanifest, and checks out the outer manifest project to that commit. Submanifests are then processed normally, allowing them to be updated to the revisions specified in the new outer manifest state. Bug: 416589884 Change-Id: I304c37a2b8794f9b74cb7e5e209a8a93762bdb52 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/576321 Commit-Queue: Gavin Mak <gavinmak@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_superproject.py')
-rw-r--r--git_superproject.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/git_superproject.py b/git_superproject.py
index 81a6b2e59..27bc10e10 100644
--- a/git_superproject.py
+++ b/git_superproject.py
@@ -34,6 +34,7 @@ import urllib.parse
34 34
35from git_command import git_require 35from git_command import git_require
36from git_command import GitCommand 36from git_command import GitCommand
37from git_config import IsId
37from git_config import RepoConfig 38from git_config import RepoConfig
38from git_refs import GitRefs 39from git_refs import GitRefs
39import platform_utils 40import platform_utils
@@ -132,6 +133,10 @@ class Superproject:
132 """Set the _print_messages attribute.""" 133 """Set the _print_messages attribute."""
133 self._print_messages = value 134 self._print_messages = value
134 135
136 def SetRevisionId(self, revision_id: str) -> None:
137 """Set the revisionId of the superproject to sync to."""
138 self.revision = revision_id
139
135 @property 140 @property
136 def commit_id(self): 141 def commit_id(self):
137 """Returns the commit ID of the superproject checkout.""" 142 """Returns the commit ID of the superproject checkout."""
@@ -314,7 +319,14 @@ class Superproject:
314 cmd.extend(["--negotiation-tip", rev_commit]) 319 cmd.extend(["--negotiation-tip", rev_commit])
315 320
316 if self.revision: 321 if self.revision:
317 cmd += [self.revision + ":" + self.revision] 322 # If revision is a commit hash, fetch it directly to avoid
323 # creating a local branch of the same name.
324 refspec = (
325 self.revision
326 if IsId(self.revision)
327 else f"{self.revision}:{self.revision}"
328 )
329 cmd.append(refspec)
318 p = GitCommand( 330 p = GitCommand(
319 None, 331 None,
320 cmd, 332 cmd,
@@ -401,6 +413,8 @@ class Superproject:
401 413
402 if not self._Init(): 414 if not self._Init():
403 return SyncResult(False, should_exit) 415 return SyncResult(False, should_exit)
416 if IsId(self.revision) and self.commit_id:
417 return SyncResult(True, False)
404 if not self._Fetch(): 418 if not self._Fetch():
405 return SyncResult(False, should_exit) 419 return SyncResult(False, should_exit)
406 if not self._quiet: 420 if not self._quiet: