aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authormatej.risek <matej.risek@hashicorp.com>2023-05-09 11:54:55 +0200
committermatej.risek <matej.risek@hashicorp.com>2023-06-05 13:59:34 +0200
commit2d6af16bf6d051cb3014c9970f3ea813e54f73b0 (patch)
tree915862150ed9b968d8da6900ebe9d48b71b4d62e /repository.go
parent1dbd729a387edb61c89f088cd68040085e6c81bb (diff)
downloadgo-git-2d6af16bf6d051cb3014c9970f3ea813e54f73b0.tar.gz
git: add a clone option to allow for shallow cloning of submodules
This option matches the git clone option --shallow-submodules. https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---no-shallow-submodules
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/repository.go b/repository.go
index 287b597..33a9d69 100644
--- a/repository.go
+++ b/repository.go
@@ -900,7 +900,13 @@ func (r *Repository) clone(ctx context.Context, o *CloneOptions) error {
if o.RecurseSubmodules != NoRecurseSubmodules {
if err := w.updateSubmodules(&SubmoduleUpdateOptions{
RecurseSubmodules: o.RecurseSubmodules,
- Auth: o.Auth,
+ Depth: func() int {
+ if o.ShallowSubmodules {
+ return 1
+ }
+ return 0
+ }(),
+ Auth: o.Auth,
}); err != nil {
return err
}