@@ -71,17 +71,48 @@ export class NoSource extends BuildSource {
71
71
}
72
72
}
73
73
74
+ /**
75
+ * The construction properties common to all build sources that are backed by Git.
76
+ */
77
+ export interface GitBuildSourceProps extends BuildSourceProps {
78
+ /**
79
+ * The depth of history to download. Minimum value is 0.
80
+ * If this value is 0, greater than 25, or not provided,
81
+ * then the full history is downloaded with each build of the project.
82
+ */
83
+ cloneDepth ?: number ;
84
+ }
85
+
86
+ /**
87
+ * A common superclass of all build sources that are backed by Git.
88
+ */
89
+ export abstract class GitBuildSource extends BuildSource {
90
+ private readonly cloneDepth ?: number ;
91
+
92
+ protected constructor ( props : GitBuildSourceProps ) {
93
+ super ( props ) ;
94
+
95
+ this . cloneDepth = props . cloneDepth ;
96
+ }
97
+
98
+ public toSourceJSON ( ) : CfnProject . SourceProperty {
99
+ const ret = super . toSourceJSON ( ) ;
100
+ ret . gitCloneDepth = this . cloneDepth ;
101
+ return ret ;
102
+ }
103
+ }
104
+
74
105
/**
75
106
* Construction properties for {@link CodeCommitSource}.
76
107
*/
77
- export interface CodeCommitSourceProps extends BuildSourceProps {
108
+ export interface CodeCommitSourceProps extends GitBuildSourceProps {
78
109
repository : codecommit . IRepository ;
79
110
}
80
111
81
112
/**
82
113
* CodeCommit Source definition for a CodeBuild project.
83
114
*/
84
- export class CodeCommitSource extends BuildSource {
115
+ export class CodeCommitSource extends GitBuildSource {
85
116
public readonly type : SourceType = SourceType . CodeCommit ;
86
117
private readonly repo : codecommit . IRepository ;
87
118
@@ -153,7 +184,7 @@ export class CodePipelineSource extends BuildSource {
153
184
/**
154
185
* Construction properties for {@link GitHubSource} and {@link GitHubEnterpriseSource}.
155
186
*/
156
- export interface GitHubSourceProps extends BuildSourceProps {
187
+ export interface GitHubSourceProps extends GitBuildSourceProps {
157
188
/**
158
189
* The GitHub account/user that owns the repo.
159
190
*
@@ -193,7 +224,7 @@ export interface GitHubSourceProps extends BuildSourceProps {
193
224
/**
194
225
* GitHub Source definition for a CodeBuild project.
195
226
*/
196
- export class GitHubSource extends BuildSource {
227
+ export class GitHubSource extends GitBuildSource {
197
228
public readonly type : SourceType = SourceType . GitHub ;
198
229
private readonly httpsCloneUrl : string ;
199
230
private readonly oauthToken : cdk . Secret ;
@@ -228,7 +259,7 @@ export class GitHubSource extends BuildSource {
228
259
/**
229
260
* Construction properties for {@link GitHubEnterpriseSource}.
230
261
*/
231
- export interface GitHubEnterpriseSourceProps extends BuildSourceProps {
262
+ export interface GitHubEnterpriseSourceProps extends GitBuildSourceProps {
232
263
/**
233
264
* The HTTPS URL of the repository in your GitHub Enterprise installation.
234
265
*/
@@ -250,8 +281,8 @@ export interface GitHubEnterpriseSourceProps extends BuildSourceProps {
250
281
/**
251
282
* GitHub Enterprise Source definition for a CodeBuild project.
252
283
*/
253
- export class GitHubEnterpriseSource extends BuildSource {
254
- public readonly type : SourceType = SourceType . GitHubEnterPrise ;
284
+ export class GitHubEnterpriseSource extends GitBuildSource {
285
+ public readonly type : SourceType = SourceType . GitHubEnterprise ;
255
286
private readonly httpsCloneUrl : string ;
256
287
private readonly oauthToken : cdk . Secret ;
257
288
private readonly ignoreSslErrors ?: boolean ;
@@ -275,7 +306,7 @@ export class GitHubEnterpriseSource extends BuildSource {
275
306
/**
276
307
* Construction properties for {@link BitBucketSource}.
277
308
*/
278
- export interface BitBucketSourceProps extends BuildSourceProps {
309
+ export interface BitBucketSourceProps extends GitBuildSourceProps {
279
310
/**
280
311
* The BitBucket account/user that owns the repo.
281
312
*
@@ -294,7 +325,7 @@ export interface BitBucketSourceProps extends BuildSourceProps {
294
325
/**
295
326
* BitBucket Source definition for a CodeBuild project.
296
327
*/
297
- export class BitBucketSource extends BuildSource {
328
+ export class BitBucketSource extends GitBuildSource {
298
329
public readonly type : SourceType = SourceType . BitBucket ;
299
330
private readonly httpsCloneUrl : any ;
300
331
@@ -318,7 +349,7 @@ export enum SourceType {
318
349
CodeCommit = 'CODECOMMIT' ,
319
350
CodePipeline = 'CODEPIPELINE' ,
320
351
GitHub = 'GITHUB' ,
321
- GitHubEnterPrise = 'GITHUB_ENTERPRISE' ,
352
+ GitHubEnterprise = 'GITHUB_ENTERPRISE' ,
322
353
BitBucket = 'BITBUCKET' ,
323
354
S3 = 'S3' ,
324
355
}
0 commit comments