diff options
-rw-r--r-- | project.py | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -642,6 +642,10 @@ class Project: | |||
642 | # project containing repo hooks. | 642 | # project containing repo hooks. |
643 | self.enabled_repo_hooks = [] | 643 | self.enabled_repo_hooks = [] |
644 | 644 | ||
645 | # This will be updated later if the project has submodules and | ||
646 | # if they will be synced. | ||
647 | self.has_subprojects = False | ||
648 | |||
645 | def RelPath(self, local=True): | 649 | def RelPath(self, local=True): |
646 | """Return the path for the project relative to a manifest. | 650 | """Return the path for the project relative to a manifest. |
647 | 651 | ||
@@ -1560,6 +1564,11 @@ class Project: | |||
1560 | return | 1564 | return |
1561 | 1565 | ||
1562 | self._InitWorkTree(force_sync=force_sync, submodules=submodules) | 1566 | self._InitWorkTree(force_sync=force_sync, submodules=submodules) |
1567 | # TODO(https://git-scm.com/docs/git-worktree#_bugs): Re-evaluate if | ||
1568 | # submodules can be init when using worktrees once its support is | ||
1569 | # complete. | ||
1570 | if self.has_subprojects and not self.use_git_worktrees: | ||
1571 | self._InitSubmodules() | ||
1563 | all_refs = self.bare_ref.all | 1572 | all_refs = self.bare_ref.all |
1564 | self.CleanPublishedCache(all_refs) | 1573 | self.CleanPublishedCache(all_refs) |
1565 | revid = self.GetRevisionId(all_refs) | 1574 | revid = self.GetRevisionId(all_refs) |
@@ -2347,6 +2356,8 @@ class Project: | |||
2347 | ) | 2356 | ) |
2348 | result.append(subproject) | 2357 | result.append(subproject) |
2349 | result.extend(subproject.GetDerivedSubprojects()) | 2358 | result.extend(subproject.GetDerivedSubprojects()) |
2359 | if result: | ||
2360 | self.has_subprojects = True | ||
2350 | return result | 2361 | return result |
2351 | 2362 | ||
2352 | def EnableRepositoryExtension(self, key, value="true", version=1): | 2363 | def EnableRepositoryExtension(self, key, value="true", version=1): |
@@ -2997,6 +3008,17 @@ class Project: | |||
2997 | project=self.name, | 3008 | project=self.name, |
2998 | ) | 3009 | ) |
2999 | 3010 | ||
3011 | def _InitSubmodules(self, quiet=True): | ||
3012 | """Initialize the submodules for the project.""" | ||
3013 | cmd = ["submodule", "init"] | ||
3014 | if quiet: | ||
3015 | cmd.append("-q") | ||
3016 | if GitCommand(self, cmd).Wait() != 0: | ||
3017 | raise GitError( | ||
3018 | f"{self.name} submodule init", | ||
3019 | project=self.name, | ||
3020 | ) | ||
3021 | |||
3000 | def _Rebase(self, upstream, onto=None): | 3022 | def _Rebase(self, upstream, onto=None): |
3001 | cmd = ["rebase"] | 3023 | cmd = ["rebase"] |
3002 | if onto is not None: | 3024 | if onto is not None: |