diff options
| author | Michael Kelly <mkelly@arista.com> | 2020-07-21 19:40:38 -0700 |
|---|---|---|
| committer | Michael Kelly <mkelly@arista.com> | 2021-09-28 20:12:00 +0000 |
| commit | 2f3c3316e497faafa1e6f3e9cb40828d0eeb9812 (patch) | |
| tree | 879470f435e54f3095424c632ae149fb4adb1186 | |
| parent | 37c21c268badc2602a827d2236027e235fff95e0 (diff) | |
| download | git-repo-2f3c3316e497faafa1e6f3e9cb40828d0eeb9812.tar.gz | |
Update revisionId if required when using extend-project
When a hard revision ID is provided in a regular project tag then the
revisionId is updated as well if it is a commit hash. The difference
is that if the revisionExpr is a commit, git-repo needs to update
refs/remotes/m/master with update-ref not symbolic-ref, as the latter
must refer to another ref, not to a specific commit.
Change-Id: I215a62dabb30225e480ad2c731416d775fc0c750
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310963
Tested-by: Michael Kelly <mkelly@arista.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
| -rw-r--r-- | manifest_xml.py | 8 | ||||
| -rw-r--r-- | project.py | 17 |
2 files changed, 12 insertions, 13 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 39656975..68ead53c 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
| @@ -887,13 +887,11 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md | |||
| 887 | if groups: | 887 | if groups: |
| 888 | p.groups.extend(groups) | 888 | p.groups.extend(groups) |
| 889 | if revision: | 889 | if revision: |
| 890 | p.revisionExpr = revision | 890 | p.SetRevision(revision) |
| 891 | if IsId(revision): | 891 | |
| 892 | p.revisionId = revision | ||
| 893 | else: | ||
| 894 | p.revisionId = None | ||
| 895 | if remote: | 892 | if remote: |
| 896 | p.remote = remote.ToRemoteSpec(name) | 893 | p.remote = remote.ToRemoteSpec(name) |
| 894 | |||
| 897 | if dest_path: | 895 | if dest_path: |
| 898 | del self._paths[p.relpath] | 896 | del self._paths[p.relpath] |
| 899 | relpath, worktree, gitdir, objdir, _ = self.GetProjectPaths(name, dest_path) | 897 | relpath, worktree, gitdir, objdir, _ = self.GetProjectPaths(name, dest_path) |
| @@ -520,14 +520,7 @@ class Project(object): | |||
| 520 | self.name = name | 520 | self.name = name |
| 521 | self.remote = remote | 521 | self.remote = remote |
| 522 | self.UpdatePaths(relpath, worktree, gitdir, objdir) | 522 | self.UpdatePaths(relpath, worktree, gitdir, objdir) |
| 523 | self.revisionExpr = revisionExpr | 523 | self.SetRevision(revisionExpr, revisionId=revisionId) |
| 524 | |||
| 525 | if revisionId is None \ | ||
| 526 | and revisionExpr \ | ||
| 527 | and IsId(revisionExpr): | ||
| 528 | self.revisionId = revisionExpr | ||
| 529 | else: | ||
| 530 | self.revisionId = revisionId | ||
| 531 | 524 | ||
| 532 | self.rebase = rebase | 525 | self.rebase = rebase |
| 533 | self.groups = groups | 526 | self.groups = groups |
| @@ -557,6 +550,14 @@ class Project(object): | |||
| 557 | # project containing repo hooks. | 550 | # project containing repo hooks. |
| 558 | self.enabled_repo_hooks = [] | 551 | self.enabled_repo_hooks = [] |
| 559 | 552 | ||
| 553 | def SetRevision(self, revisionExpr, revisionId=None): | ||
| 554 | """Set revisionId based on revision expression and id""" | ||
| 555 | self.revisionExpr = revisionExpr | ||
| 556 | if revisionId is None and revisionExpr and IsId(revisionExpr): | ||
| 557 | self.revisionId = self.revisionExpr | ||
| 558 | else: | ||
| 559 | self.revisionId = revisionId | ||
| 560 | |||
| 560 | def UpdatePaths(self, relpath, worktree, gitdir, objdir): | 561 | def UpdatePaths(self, relpath, worktree, gitdir, objdir): |
| 561 | """Update paths used by this project""" | 562 | """Update paths used by this project""" |
| 562 | self.gitdir = gitdir.replace('\\', '/') | 563 | self.gitdir = gitdir.replace('\\', '/') |
