Skip to content

Commit 8a0ae52

Browse files
committed
Shallow git clone for better performance
Do not download the entire commit history from the remote. Execute the equivalent of `git clone --depth 1` Fixes spring-cloud#1544
1 parent c372fcf commit 8a0ae52

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,8 @@ private Git copyFromLocalRepository() throws IOException {
652652

653653
private Git cloneToBasedir() throws GitAPIException {
654654
CloneCommand clone = this.gitFactory.getCloneCommandByCloneRepository().setURI(getUri())
655-
.setDirectory(getBasedir());
655+
.setDirectory(getBasedir())
656+
.setDepth(1);
656657
configureCommand(clone);
657658
try {
658659
return clone.call();
@@ -772,7 +773,8 @@ 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)
777+
.setDepth(1);
776778
return command;
777779
}
778780

0 commit comments

Comments
 (0)