Skip to content

Commit

Permalink
Shallow git clone for better performance
Browse files Browse the repository at this point in the history
Do not download the entire commit history from the remote.  Execute the
equivalent of `git clone --depth 1`

Fixes spring-cloud#1544
  • Loading branch information
pukkaone committed Apr 9, 2024
1 parent c372fcf commit 2e13af5
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
* @author Ryan Lynch
* @author Gareth Clay
* @author ChaoDong Xi
* @author Chin Huang
*/
public class JGitEnvironmentRepository extends AbstractScmEnvironmentRepository
implements EnvironmentRepository, SearchPathLocator, InitializingBean {
Expand Down Expand Up @@ -652,7 +653,7 @@ private Git copyFromLocalRepository() throws IOException {

private Git cloneToBasedir() throws GitAPIException {
CloneCommand clone = this.gitFactory.getCloneCommandByCloneRepository().setURI(getUri())
.setDirectory(getBasedir());
.setDirectory(getBasedir()).setDepth(1);
configureCommand(clone);
try {
return clone.call();
Expand Down Expand Up @@ -772,7 +773,7 @@ public Git getGitByOpen(File file) throws IOException {
}

public CloneCommand getCloneCommandByCloneRepository() {
CloneCommand command = Git.cloneRepository().setCloneSubmodules(cloneSubmodules);
CloneCommand command = Git.cloneRepository().setCloneSubmodules(cloneSubmodules).setDepth(1);
return command;
}

Expand Down

0 comments on commit 2e13af5

Please sign in to comment.