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 /project.py | |
| 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>
Diffstat (limited to 'project.py')
| -rw-r--r-- | project.py | 17 |
1 files changed, 9 insertions, 8 deletions
| @@ -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('\\', '/') |
