Skip to content

Commit 68f2926

Browse files
committed
Git shallow clone for better performance
Do not download the entire commit history from the remote. Execute the equivalent of `git clone --depth 1` Fixes #1544
1 parent c372fcf commit 68f2926

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
* @author Ryan Lynch
7878
* @author Gareth Clay
7979
* @author ChaoDong Xi
80+
* @author Chin Huang
8081
*/
8182
public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository
8283
implements EnvironmentRepository, SearchPathLocator, InitializingBean {
@@ -652,7 +653,7 @@ private Git copyFromLocalRepository() throws IOException {
652653

653654
private Git cloneToBasedir() throws GitAPIException {
654655
CloneCommand clone = this.gitFactory.getCloneCommandByCloneRepository().setURI(getUri())
655-
.setDirectory(getBasedir());
656+
.setDirectory(getBasedir()).setDepth(1);
656657
configureCommand(clone);
657658
try {
658659
return clone.call();
@@ -772,7 +773,7 @@ public Git getGitByOpen(File file) throws IOException {
772773
}
773774

774775
public CloneCommand getCloneCommandByCloneRepository() {
775-
CloneCommand command = Git.cloneRepository().setCloneSubmodules(cloneSubmodules);
776+
CloneCommand command = Git.cloneRepository().setCloneSubmodules(cloneSubmodules).setDepth(1);
776777
return command;
777778
}
778779

0 commit comments

Comments
 (0)