mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-02-06 12:08:54 +00:00
Activate submodules
This change moves further towards ensuring Git can understand repo's submodules. 'submodule init' is used to make the submodules active[1]. [1] https://git-scm.com/docs/gitsubmodules#_active_submodules Change-Id: I0c20ff1991101fc5be171e566d8fb644aab47200 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/446182 Tested-by: Kaushik Lingarkar <kaushikl@qti.qualcomm.com> Reviewed-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
66685f07ec
commit
99eca45eb2
22
project.py
22
project.py
@ -642,6 +642,10 @@ class Project:
|
|||||||
# project containing repo hooks.
|
# project containing repo hooks.
|
||||||
self.enabled_repo_hooks = []
|
self.enabled_repo_hooks = []
|
||||||
|
|
||||||
|
# This will be updated later if the project has submodules and
|
||||||
|
# if they will be synced.
|
||||||
|
self.has_subprojects = False
|
||||||
|
|
||||||
def RelPath(self, local=True):
|
def RelPath(self, local=True):
|
||||||
"""Return the path for the project relative to a manifest.
|
"""Return the path for the project relative to a manifest.
|
||||||
|
|
||||||
@ -1560,6 +1564,11 @@ class Project:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self._InitWorkTree(force_sync=force_sync, submodules=submodules)
|
self._InitWorkTree(force_sync=force_sync, submodules=submodules)
|
||||||
|
# TODO(https://git-scm.com/docs/git-worktree#_bugs): Re-evaluate if
|
||||||
|
# submodules can be init when using worktrees once its support is
|
||||||
|
# complete.
|
||||||
|
if self.has_subprojects and not self.use_git_worktrees:
|
||||||
|
self._InitSubmodules()
|
||||||
all_refs = self.bare_ref.all
|
all_refs = self.bare_ref.all
|
||||||
self.CleanPublishedCache(all_refs)
|
self.CleanPublishedCache(all_refs)
|
||||||
revid = self.GetRevisionId(all_refs)
|
revid = self.GetRevisionId(all_refs)
|
||||||
@ -2347,6 +2356,8 @@ class Project:
|
|||||||
)
|
)
|
||||||
result.append(subproject)
|
result.append(subproject)
|
||||||
result.extend(subproject.GetDerivedSubprojects())
|
result.extend(subproject.GetDerivedSubprojects())
|
||||||
|
if result:
|
||||||
|
self.has_subprojects = True
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def EnableRepositoryExtension(self, key, value="true", version=1):
|
def EnableRepositoryExtension(self, key, value="true", version=1):
|
||||||
@ -2997,6 +3008,17 @@ class Project:
|
|||||||
project=self.name,
|
project=self.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _InitSubmodules(self, quiet=True):
|
||||||
|
"""Initialize the submodules for the project."""
|
||||||
|
cmd = ["submodule", "init"]
|
||||||
|
if quiet:
|
||||||
|
cmd.append("-q")
|
||||||
|
if GitCommand(self, cmd).Wait() != 0:
|
||||||
|
raise GitError(
|
||||||
|
f"{self.name} submodule init",
|
||||||
|
project=self.name,
|
||||||
|
)
|
||||||
|
|
||||||
def _Rebase(self, upstream, onto=None):
|
def _Rebase(self, upstream, onto=None):
|
||||||
cmd = ["rebase"]
|
cmd = ["rebase"]
|
||||||
if onto is not None:
|
if onto is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user