@@ -38,24 +38,25 @@ func CheckoutStrategyForRef(ref *sourcev1.GitRepositoryRef) git.CheckoutStrategy
38
38
case ref == nil :
39
39
return & CheckoutBranch {branch : git .DefaultBranch }
40
40
case ref .SemVer != "" :
41
- return & CheckoutSemVer {semVer : ref .SemVer }
41
+ return & CheckoutSemVer {semVer : ref .SemVer , recurseSubmodules : ref . RecurseSubmodules }
42
42
case ref .Tag != "" :
43
- return & CheckoutTag {tag : ref .Tag }
43
+ return & CheckoutTag {tag : ref .Tag , recurseSubmodules : ref . RecurseSubmodules }
44
44
case ref .Commit != "" :
45
- strategy := & CheckoutCommit {branch : ref .Branch , commit : ref .Commit }
45
+ strategy := & CheckoutCommit {branch : ref .Branch , commit : ref .Commit , recurseSubmodules : ref . RecurseSubmodules }
46
46
if strategy .branch == "" {
47
47
strategy .branch = git .DefaultBranch
48
48
}
49
49
return strategy
50
50
case ref .Branch != "" :
51
- return & CheckoutBranch {branch : ref .Branch }
51
+ return & CheckoutBranch {branch : ref .Branch , recurseSubmodules : ref . RecurseSubmodules }
52
52
default :
53
53
return & CheckoutBranch {branch : git .DefaultBranch }
54
54
}
55
55
}
56
56
57
57
type CheckoutBranch struct {
58
- branch string
58
+ branch string
59
+ recurseSubmodules bool
59
60
}
60
61
61
62
func (c * CheckoutBranch ) Checkout (ctx context.Context , path , url string , auth * git.Auth ) (git.Commit , string , error ) {
@@ -67,7 +68,7 @@ func (c *CheckoutBranch) Checkout(ctx context.Context, path, url string, auth *g
67
68
SingleBranch : true ,
68
69
NoCheckout : false ,
69
70
Depth : 1 ,
70
- RecurseSubmodules : extgogit . DefaultSubmoduleRecursionDepth ,
71
+ RecurseSubmodules : recurseSubmodules ( c . recurseSubmodules ) ,
71
72
Progress : nil ,
72
73
Tags : extgogit .NoTags ,
73
74
CABundle : auth .CABundle ,
@@ -87,7 +88,8 @@ func (c *CheckoutBranch) Checkout(ctx context.Context, path, url string, auth *g
87
88
}
88
89
89
90
type CheckoutTag struct {
90
- tag string
91
+ tag string
92
+ recurseSubmodules bool
91
93
}
92
94
93
95
func (c * CheckoutTag ) Checkout (ctx context.Context , path , url string , auth * git.Auth ) (git.Commit , string , error ) {
@@ -99,7 +101,7 @@ func (c *CheckoutTag) Checkout(ctx context.Context, path, url string, auth *git.
99
101
SingleBranch : true ,
100
102
NoCheckout : false ,
101
103
Depth : 1 ,
102
- RecurseSubmodules : extgogit . DefaultSubmoduleRecursionDepth ,
104
+ RecurseSubmodules : recurseSubmodules ( c . recurseSubmodules ) ,
103
105
Progress : nil ,
104
106
Tags : extgogit .NoTags ,
105
107
CABundle : auth .CABundle ,
@@ -119,8 +121,9 @@ func (c *CheckoutTag) Checkout(ctx context.Context, path, url string, auth *git.
119
121
}
120
122
121
123
type CheckoutCommit struct {
122
- branch string
123
- commit string
124
+ branch string
125
+ commit string
126
+ recurseSubmodules bool
124
127
}
125
128
126
129
func (c * CheckoutCommit ) Checkout (ctx context.Context , path , url string , auth * git.Auth ) (git.Commit , string , error ) {
@@ -131,7 +134,7 @@ func (c *CheckoutCommit) Checkout(ctx context.Context, path, url string, auth *g
131
134
ReferenceName : plumbing .NewBranchReferenceName (c .branch ),
132
135
SingleBranch : true ,
133
136
NoCheckout : false ,
134
- RecurseSubmodules : extgogit . DefaultSubmoduleRecursionDepth ,
137
+ RecurseSubmodules : recurseSubmodules ( c . recurseSubmodules ) ,
135
138
Progress : nil ,
136
139
Tags : extgogit .NoTags ,
137
140
CABundle : auth .CABundle ,
@@ -158,7 +161,8 @@ func (c *CheckoutCommit) Checkout(ctx context.Context, path, url string, auth *g
158
161
}
159
162
160
163
type CheckoutSemVer struct {
161
- semVer string
164
+ semVer string
165
+ recurseSubmodules bool
162
166
}
163
167
164
168
func (c * CheckoutSemVer ) Checkout (ctx context.Context , path , url string , auth * git.Auth ) (git.Commit , string , error ) {
@@ -173,7 +177,7 @@ func (c *CheckoutSemVer) Checkout(ctx context.Context, path, url string, auth *g
173
177
RemoteName : git .DefaultOrigin ,
174
178
NoCheckout : false ,
175
179
Depth : 1 ,
176
- RecurseSubmodules : extgogit . DefaultSubmoduleRecursionDepth ,
180
+ RecurseSubmodules : recurseSubmodules ( c . recurseSubmodules ) ,
177
181
Progress : nil ,
178
182
Tags : extgogit .AllTags ,
179
183
CABundle : auth .CABundle ,
@@ -262,3 +266,10 @@ func (c *CheckoutSemVer) Checkout(ctx context.Context, path, url string, auth *g
262
266
263
267
return & Commit {commit }, fmt .Sprintf ("%s/%s" , t , head .Hash ().String ()), nil
264
268
}
269
+
270
+ func recurseSubmodules (recurse bool ) extgogit.SubmoduleRescursivity {
271
+ if recurse {
272
+ return extgogit .DefaultSubmoduleRecursionDepth
273
+ }
274
+ return extgogit .NoRecurseSubmodules
275
+ }
0 commit comments