diff options
Diffstat (limited to 'git_superproject.py')
| -rw-r--r-- | git_superproject.py | 16 |
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 | ||
| 35 | from git_command import git_require | 35 | from git_command import git_require |
| 36 | from git_command import GitCommand | 36 | from git_command import GitCommand |
| 37 | from git_config import IsId | ||
| 37 | from git_config import RepoConfig | 38 | from git_config import RepoConfig |
| 38 | from git_refs import GitRefs | 39 | from git_refs import GitRefs |
| 39 | import platform_utils | 40 | import 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: |
