Skip to content

feat(util/git): support checkout depth in submodules#26777

Open
squat wants to merge 1 commit intoargoproj:masterfrom
squat:pass_checkout_depth_to_submodules
Open

feat(util/git): support checkout depth in submodules#26777
squat wants to merge 1 commit intoargoproj:masterfrom
squat:pass_checkout_depth_to_submodules

Conversation

@squat
Copy link

@squat squat commented Mar 10, 2026

This commit adds support for configuring the checkout depth of
submodules. The simple approach here in this PR is to use the global
depth configured for the repository for the submodule.
In my opinion, this is the most logical way to treat the current
configuration surface, which only exposes a single field to configure
the checkout depth of a monorepo. Rather than add more knobs to tune
the checkout depth of every single different submodule in a repo, this
commit takes the simple approach of applying the depth globally to all
submodules.

The commit introduces new unit tests to validate that shallow checkouts
work for submodules.

Fixes: #26774

Signed-off-by: squat lserven@gmail.com

@squat squat requested a review from a team as a code owner March 10, 2026 18:10
@bunnyshell
Copy link

bunnyshell bot commented Mar 10, 2026

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@squat squat force-pushed the pass_checkout_depth_to_submodules branch 4 times, most recently from ea2b708 to 2ec4076 Compare March 10, 2026 19:20
@squat
Copy link
Author

squat commented Mar 10, 2026

I'm pretty sure the failure in the unit test is a flake because the test is timing out while trying to clone from github; this is likely hitting network issues or rate limits.

@squat squat force-pushed the pass_checkout_depth_to_submodules branch from 8759ec2 to fa5cc24 Compare March 10, 2026 20:29
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.05%. Comparing base (63a009e) to head (40cf85e).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #26777      +/-   ##
==========================================
+ Coverage   63.04%   63.05%   +0.01%     
==========================================
  Files         414      414              
  Lines       56286    56294       +8     
==========================================
+ Hits        35484    35496      +12     
  Misses      17427    17427              
+ Partials     3375     3371       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@olivergondza
Copy link
Contributor

@squat, I like the idea of propagating the git --depth into submodules.

Have you considered refactoring the depth into one of the client options (would require changing Fetch(revision string, depth int64)), so it does not have to be passed over and over through several client methods? It is configured per-repository anyway...

Copy link
Member

@choejwoo choejwoo left a comment

Choose a reason for hiding this comment

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

+1 to @olivergondza suggestion.
Would it be cleaner to make depth a client option, since it is repo-level config, instead of threading it through multiple methods?

@squat squat force-pushed the pass_checkout_depth_to_submodules branch 4 times, most recently from be38c86 to e990b47 Compare March 16, 2026 16:55
@squat
Copy link
Author

squat commented Mar 16, 2026

@olivergondza @choejwoo thanks for taking a look at this changeset! On the subject of the specifying the clone depth for the client, agreed, I think that setting the depth once as an option on the nativeGitClient struct is cleaner and less repetitive. I just pushed a new commit to incorporate that suggestions and the result is indeed much cleaner. PTAL when you can!

This commit adds support for configuring the checkout depth of
submodules. The simple approach here in this PR is to use the global
depth configured for the repository for the submodule.
In my opinion, this is the most logical way to treat the current
configuration surface, which only exposes a single field to configure
the checkout depth of a monorepo. Rather than add more knobs to tune
the checkout depth of every single different submodule in a repo, this
commit takes the simple approach of applying the depth globally to all
submodules.

The commit introduces new unit tests to validate that shallow checkouts
work for submodules.

Notably, this commit changes the signature of the `Fetch` method on the
Git client interface to no longer accept an argument for the checkout
depth. Instead, the depth is now configured as an option massed to the
Git client initializer: `WithDepth(<depth>)`.

Fixes: argoproj#26774

Signed-off-by: squat <lserven@gmail.com>
@squat squat force-pushed the pass_checkout_depth_to_submodules branch from e990b47 to 40cf85e Compare March 16, 2026 17:09
@squat squat requested a review from choejwoo March 16, 2026 17:14
Copy link
Contributor

@olivergondza olivergondza left a comment

Choose a reason for hiding this comment

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

Perfect, looks nicer!

@olivergondza olivergondza added the ready-for-review An approver should give a final review and merge the PR label Mar 16, 2026
@github-project-automation github-project-automation bot moved this to Ready for final review in Argo CD Review Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review An approver should give a final review and merge the PR

Projects

Status: Ready for final review

Development

Successfully merging this pull request may close these issues.

Support Shallow Clones for Git Submodules

3 participants