Skip to content

Comments

camel-git - Add depth option to provide shallow clone#21581

Merged
Croway merged 1 commit intoapache:mainfrom
Croway:git-shallow
Feb 23, 2026
Merged

camel-git - Add depth option to provide shallow clone#21581
Croway merged 1 commit intoapache:mainfrom
Croway:git-shallow

Conversation

@Croway
Copy link
Contributor

@Croway Croway commented Feb 23, 2026

No description provided.

@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

Comment on lines +102 to +103
case BRANCH -> new GitBranchConsumer(this, processor);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the behavior change done on purpose in case the type is not part of the list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a small refactor, and since GitType is an enum, the default is unnecessary, the default branch is dead code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type can be null

}
var cloneCommand = Git.cloneRepository()
.setURI(endpoint.getRemotePath())
.setDirectory(new File(endpoint.getLocalPath()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not reusing directly localRepo variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, thanks

.to("git:///tmp/myRepo?operation=clone&remotePath=https://github.com/example/repo.git&depth=1");
---------------------------------------

A `depth` of 1 fetches only the latest commit. When set to 0 or omitted, a full clone is performed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

based on implementation, it is when set to 0 or less than 0 or omitted

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when depth is omitted, private int depth; defaults to 0, therefore, it should be correct, am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if depth is set to a negative number, it is doing a full clone

@Croway Croway merged commit 431dbd0 into apache:main Feb 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants