Adds option to clone git submodules.
Fixes gh-717 Fixes gh-1484
This commit is contained in:
@@ -40,6 +40,11 @@ public class JGitEnvironmentProperties extends AbstractScmAccessorProperties
|
||||
*/
|
||||
private boolean cloneOnStart = false;
|
||||
|
||||
/**
|
||||
* Flag to indicate that the submodules in the repository should be cloned.
|
||||
*/
|
||||
private boolean cloneSubmodules = false;
|
||||
|
||||
/**
|
||||
* Flag to indicate that the repository should force pull. If true discard any local
|
||||
* changes and take from remote repository.
|
||||
@@ -127,6 +132,14 @@ public class JGitEnvironmentProperties extends AbstractScmAccessorProperties
|
||||
this.cloneOnStart = cloneOnStart;
|
||||
}
|
||||
|
||||
public boolean isCloneSubmodules() {
|
||||
return this.cloneSubmodules;
|
||||
}
|
||||
|
||||
public void setCloneSubmodules(boolean cloneSubmodules) {
|
||||
this.cloneSubmodules = cloneSubmodules;
|
||||
}
|
||||
|
||||
public boolean isForcePull() {
|
||||
return this.forcePull;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository
|
||||
*/
|
||||
private boolean cloneOnStart;
|
||||
|
||||
private JGitEnvironmentRepository.JGitFactory gitFactory = new JGitEnvironmentRepository.JGitFactory();
|
||||
private JGitEnvironmentRepository.JGitFactory gitFactory;
|
||||
|
||||
private String defaultLabel;
|
||||
|
||||
@@ -157,6 +157,7 @@ public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository
|
||||
this.deleteUntrackedBranches = properties.isDeleteUntrackedBranches();
|
||||
this.refreshRate = properties.getRefreshRate();
|
||||
this.skipSslValidation = properties.isSkipSslValidation();
|
||||
this.gitFactory = new JGitFactory(properties.isCloneSubmodules());
|
||||
}
|
||||
|
||||
public boolean isCloneOnStart() {
|
||||
@@ -705,13 +706,24 @@ public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository
|
||||
*/
|
||||
public static class JGitFactory {
|
||||
|
||||
private final boolean cloneSubmodules;
|
||||
|
||||
public JGitFactory() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public JGitFactory(boolean cloneSubmodules) {
|
||||
this.cloneSubmodules = cloneSubmodules;
|
||||
}
|
||||
|
||||
public Git getGitByOpen(File file) throws IOException {
|
||||
Git git = Git.open(file);
|
||||
return git;
|
||||
}
|
||||
|
||||
public CloneCommand getCloneCommandByCloneRepository() {
|
||||
CloneCommand command = Git.cloneRepository();
|
||||
CloneCommand command = Git.cloneRepository()
|
||||
.setCloneSubmodules(cloneSubmodules);
|
||||
return command;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user