Merge branch '2.2.x'

This commit is contained in:
spencergibb
2020-11-12 17:25:02 -05:00
2 changed files with 27 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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;
@@ -156,6 +156,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() {
@@ -679,13 +680,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;
}