Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set fetch depth #56

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class GitConfiguration implements AutoloadedConfigurations {
public static final ConfigurationDefinition<String> GIT_PATH;
public static final ConfigurationDefinition<String> GIT_BRANCH;
public static final ConfigurationDefinition<Boolean> GIT_CLEANUP;
public static final ConfigurationDefinition<Integer> GIT_FETCH_DEPTH;

static {
ConfigurationDefinition.Builder builder = new ConfigurationDefinition.Builder("liquibase.git");
Expand All @@ -37,6 +38,10 @@ public class GitConfiguration implements AutoloadedConfigurations {
.setDescription("Remove local repository path after run")
.setDefaultValue(true)
.build();
GIT_FETCH_DEPTH = builder.define("fetch_depth", Integer.class)
.addAliasKey("git.fetch_depth")
.setDescription("Creates a shallow clone with a history truncated to the specified number of commits")
.build();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ private boolean hasGitCredentials(String username, String password) throws IOExc
private CloneCommand getCloneCommand(String root, File path, String branch) throws IOException {
String username = GitConfiguration.GIT_USERNAME.getCurrentValue();
String password = GitConfiguration.GIT_PASSWORD.getCurrentValue();

Integer depth = GitConfiguration.GIT_FETCH_DEPTH.getCurrentValue();

CloneCommand cloneCommand = Git.cloneRepository().setURI(root);
cloneCommand.setDirectory(path);
if (this.hasGitCredentials(username, password)) {
Expand All @@ -117,6 +118,9 @@ private CloneCommand getCloneCommand(String root, File path, String branch) thro
if (branch != null && !branch.equals("")) {
cloneCommand.setBranch(branch);
}
if (depth != null && depth > 0) {
cloneCommand.setDepth(depth);
}

return cloneCommand;
}
Expand Down
Loading