summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/project.py b/project.py
index de1ab3c6..b58bd53b 100644
--- a/project.py
+++ b/project.py
@@ -3415,6 +3415,11 @@ class Project:
3415 """ 3415 """
3416 dotgit = os.path.join(self.worktree, ".git") 3416 dotgit = os.path.join(self.worktree, ".git")
3417 3417
3418 # If bare checkout of the submodule is stored under the subproject dir,
3419 # migrate it.
3420 if self.parent:
3421 self._MigrateOldSubmoduleDir()
3422
3418 # If using an old layout style (a directory), migrate it. 3423 # If using an old layout style (a directory), migrate it.
3419 if not platform_utils.islink(dotgit) and platform_utils.isdir(dotgit): 3424 if not platform_utils.islink(dotgit) and platform_utils.isdir(dotgit):
3420 self._MigrateOldWorkTreeGitDir(dotgit, project=self.name) 3425 self._MigrateOldWorkTreeGitDir(dotgit, project=self.name)
@@ -3548,6 +3553,28 @@ class Project:
3548 dotgit, 3553 dotgit,
3549 ) 3554 )
3550 3555
3556 def _MigrateOldSubmoduleDir(self):
3557 """Move the old bare checkout in 'subprojects' to 'modules'
3558 as bare checkouts of submodules are now in 'modules' dir.
3559 """
3560 subprojects = os.path.join(self.parent.gitdir, "subprojects")
3561 if not platform_utils.isdir(subprojects):
3562 return
3563
3564 modules = os.path.join(self.parent.gitdir, "modules")
3565 old = self.gitdir
3566 new = os.path.splitext(self.gitdir.replace(subprojects, modules))[0]
3567
3568 if all(map(platform_utils.isdir, [old, new])):
3569 platform_utils.rmtree(old, ignore_errors=True)
3570 else:
3571 os.makedirs(modules, exist_ok=True)
3572 platform_utils.rename(old, new)
3573 self.gitdir = new
3574 self.UpdatePaths(self.relpath, self.worktree, self.gitdir, self.objdir)
3575 if platform_utils.isdir(subprojects) and not os.listdir(subprojects):
3576 platform_utils.rmtree(subprojects, ignore_errors=True)
3577
3551 def _get_symlink_error_message(self): 3578 def _get_symlink_error_message(self):
3552 if platform_utils.isWindows(): 3579 if platform_utils.isWindows():
3553 return ( 3580 return (