diff options
author | Michael Kelly <mkelly@arista.com> | 2020-06-13 02:10:40 -0700 |
---|---|---|
committer | Michael Kelly <mkelly@arista.com> | 2021-09-28 20:12:00 +0000 |
commit | 37c21c268badc2602a827d2236027e235fff95e0 (patch) | |
tree | d2d8c1b751e38036acb6a530bea9b6dae121147b /project.py | |
parent | b12c369e0bce29914a50aca258271b25893d2857 (diff) | |
download | git-repo-37c21c268badc2602a827d2236027e235fff95e0.tar.gz |
Add 'dest-path' to extend-project to support changing path
This allows us to move the repository to a new location in the source
tree without having to remove-project + add a new project tag.
Change-Id: I4dba6151842e57f6f2b8fe60cda260ecea68b7b4
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/310962
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Michael Kelly <mkelly@arista.com>
Diffstat (limited to 'project.py')
-rw-r--r-- | project.py | 39 |
1 files changed, 22 insertions, 17 deletions
@@ -519,13 +519,7 @@ class Project(object): | |||
519 | self.client = self.manifest = manifest | 519 | self.client = self.manifest = manifest |
520 | self.name = name | 520 | self.name = name |
521 | self.remote = remote | 521 | self.remote = remote |
522 | self.gitdir = gitdir.replace('\\', '/') | 522 | self.UpdatePaths(relpath, worktree, gitdir, objdir) |
523 | self.objdir = objdir.replace('\\', '/') | ||
524 | if worktree: | ||
525 | self.worktree = os.path.normpath(worktree).replace('\\', '/') | ||
526 | else: | ||
527 | self.worktree = None | ||
528 | self.relpath = relpath | ||
529 | self.revisionExpr = revisionExpr | 523 | self.revisionExpr = revisionExpr |
530 | 524 | ||
531 | if revisionId is None \ | 525 | if revisionId is None \ |
@@ -556,16 +550,6 @@ class Project(object): | |||
556 | self.copyfiles = [] | 550 | self.copyfiles = [] |
557 | self.linkfiles = [] | 551 | self.linkfiles = [] |
558 | self.annotations = [] | 552 | self.annotations = [] |
559 | self.config = GitConfig.ForRepository(gitdir=self.gitdir, | ||
560 | defaults=self.client.globalConfig) | ||
561 | |||
562 | if self.worktree: | ||
563 | self.work_git = self._GitGetByExec(self, bare=False, gitdir=gitdir) | ||
564 | else: | ||
565 | self.work_git = None | ||
566 | self.bare_git = self._GitGetByExec(self, bare=True, gitdir=gitdir) | ||
567 | self.bare_ref = GitRefs(gitdir) | ||
568 | self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=objdir) | ||
569 | self.dest_branch = dest_branch | 553 | self.dest_branch = dest_branch |
570 | self.old_revision = old_revision | 554 | self.old_revision = old_revision |
571 | 555 | ||
@@ -573,6 +557,27 @@ class Project(object): | |||
573 | # project containing repo hooks. | 557 | # project containing repo hooks. |
574 | self.enabled_repo_hooks = [] | 558 | self.enabled_repo_hooks = [] |
575 | 559 | ||
560 | def UpdatePaths(self, relpath, worktree, gitdir, objdir): | ||
561 | """Update paths used by this project""" | ||
562 | self.gitdir = gitdir.replace('\\', '/') | ||
563 | self.objdir = objdir.replace('\\', '/') | ||
564 | if worktree: | ||
565 | self.worktree = os.path.normpath(worktree).replace('\\', '/') | ||
566 | else: | ||
567 | self.worktree = None | ||
568 | self.relpath = relpath | ||
569 | |||
570 | self.config = GitConfig.ForRepository(gitdir=self.gitdir, | ||
571 | defaults=self.manifest.globalConfig) | ||
572 | |||
573 | if self.worktree: | ||
574 | self.work_git = self._GitGetByExec(self, bare=False, gitdir=self.gitdir) | ||
575 | else: | ||
576 | self.work_git = None | ||
577 | self.bare_git = self._GitGetByExec(self, bare=True, gitdir=self.gitdir) | ||
578 | self.bare_ref = GitRefs(self.gitdir) | ||
579 | self.bare_objdir = self._GitGetByExec(self, bare=True, gitdir=self.objdir) | ||
580 | |||
576 | @property | 581 | @property |
577 | def Derived(self): | 582 | def Derived(self): |
578 | return self.is_derived | 583 | return self.is_derived |