Add new submodule layout to SubmoduleAddCommand
The new submodule layout where GITDIR of a submodule is located at <parent-repo-GITDIR>/modules/<submodule-path> was only used during clone. Teach SubmoduleAddCommand to use the new layout. Bug: 469666 Change-Id: Ie97dc0607b71499560444616f362bccee9cce515 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
2508f1695f
commit
4531259613
|
@ -391,6 +391,17 @@ public void testCloneRepositoryWithSubmodules() throws Exception {
|
||||||
git.add().addFilepattern(path)
|
git.add().addFilepattern(path)
|
||||||
.addFilepattern(Constants.DOT_GIT_MODULES).call();
|
.addFilepattern(Constants.DOT_GIT_MODULES).call();
|
||||||
git.commit().setMessage("adding submodule").call();
|
git.commit().setMessage("adding submodule").call();
|
||||||
|
try (SubmoduleWalk walk = SubmoduleWalk.forIndex(git.getRepository())) {
|
||||||
|
assertTrue(walk.next());
|
||||||
|
Repository subRepo = walk.getRepository();
|
||||||
|
addRepoToClose(subRepo);
|
||||||
|
assertNotNull(subRepo);
|
||||||
|
assertEquals(
|
||||||
|
new File(git.getRepository().getWorkTree(), walk.getPath()),
|
||||||
|
subRepo.getWorkTree());
|
||||||
|
assertEquals(new File(new File(git.getRepository().getDirectory(),
|
||||||
|
"modules"), walk.getPath()), subRepo.getDirectory());
|
||||||
|
}
|
||||||
|
|
||||||
File directory = createTempDirectory("testCloneRepositoryWithSubmodules");
|
File directory = createTempDirectory("testCloneRepositoryWithSubmodules");
|
||||||
CloneCommand clone = Git.cloneRepository();
|
CloneCommand clone = Git.cloneRepository();
|
||||||
|
|
|
@ -173,6 +173,8 @@ public Repository call() throws GitAPIException {
|
||||||
CloneCommand clone = Git.cloneRepository();
|
CloneCommand clone = Git.cloneRepository();
|
||||||
configure(clone);
|
configure(clone);
|
||||||
clone.setDirectory(moduleDirectory);
|
clone.setDirectory(moduleDirectory);
|
||||||
|
clone.setGitDir(new File(new File(repo.getDirectory(),
|
||||||
|
Constants.MODULES), path));
|
||||||
clone.setURI(resolvedUri);
|
clone.setURI(resolvedUri);
|
||||||
if (monitor != null)
|
if (monitor != null)
|
||||||
clone.setProgressMonitor(monitor);
|
clone.setProgressMonitor(monitor);
|
||||||
|
|
Loading…
Reference in New Issue