@@ -26,14 +26,14 @@ import (
26
26
scut "github.com/ossf/scorecard/v5/utests"
27
27
)
28
28
29
- func getBranchName (branch * clients.BranchRef ) string {
29
+ func getBranchName (branch * clients.RepoRef ) string {
30
30
if branch == nil || branch .Name == nil {
31
31
return ""
32
32
}
33
33
return * branch .Name
34
34
}
35
35
36
- func getBranch (branches []* clients.BranchRef , name string , isNonAdmin bool ) * clients.BranchRef {
36
+ func getBranch (branches []* clients.RepoRef , name string , isNonAdmin bool ) * clients.RepoRef {
37
37
for _ , branch := range branches {
38
38
branchName := getBranchName (branch )
39
39
if branchName == name {
@@ -46,9 +46,9 @@ func getBranch(branches []*clients.BranchRef, name string, isNonAdmin bool) *cli
46
46
return nil
47
47
}
48
48
49
- func scrubBranch (branch * clients.BranchRef ) * clients.BranchRef {
49
+ func scrubBranch (branch * clients.RepoRef ) * clients.RepoRef {
50
50
ret := branch
51
- ret .BranchProtectionRule = clients.BranchProtectionRule {}
51
+ ret .ProtectionRule = clients.ProtectionRule {}
52
52
return ret
53
53
}
54
54
@@ -67,7 +67,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
67
67
tests := []struct {
68
68
name string
69
69
defaultBranch string
70
- branches []* clients.BranchRef
70
+ branches []* clients.RepoRef
71
71
releases []string
72
72
repoFiles []string
73
73
expected scut.TestReturn
@@ -83,10 +83,10 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
83
83
NumberOfDebug : 0 ,
84
84
},
85
85
defaultBranch : main ,
86
- branches : []* clients.BranchRef {
86
+ branches : []* clients.RepoRef {
87
87
{
88
88
Protected : & trueVal ,
89
- BranchProtectionRule : clients.BranchProtectionRule {
89
+ ProtectionRule : clients.ProtectionRule {
90
90
CheckRules : clients.StatusChecksRule {
91
91
RequiresStatusChecks : & trueVal ,
92
92
UpToDateBeforeMerge : & trueVal ,
@@ -106,7 +106,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
106
106
},
107
107
{
108
108
Protected : & trueVal ,
109
- BranchProtectionRule : clients.BranchProtectionRule {
109
+ ProtectionRule : clients.ProtectionRule {
110
110
CheckRules : clients.StatusChecksRule {
111
111
RequiresStatusChecks : & trueVal ,
112
112
UpToDateBeforeMerge : & falseVal ,
@@ -138,15 +138,15 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
138
138
NumberOfDebug : 0 ,
139
139
},
140
140
defaultBranch : main ,
141
- branches : []* clients.BranchRef {
141
+ branches : []* clients.RepoRef {
142
142
{
143
143
Name : & rel1 ,
144
144
Protected : & falseVal ,
145
145
},
146
146
{
147
147
Name : & main ,
148
148
Protected : & trueVal ,
149
- BranchProtectionRule : clients.BranchProtectionRule {
149
+ ProtectionRule : clients.ProtectionRule {
150
150
CheckRules : clients.StatusChecksRule {
151
151
RequiresStatusChecks : & trueVal ,
152
152
UpToDateBeforeMerge : & falseVal ,
@@ -178,11 +178,11 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
178
178
NumberOfDebug : 0 ,
179
179
},
180
180
defaultBranch : main ,
181
- branches : []* clients.BranchRef {
181
+ branches : []* clients.RepoRef {
182
182
{
183
183
Name : & main ,
184
184
Protected : & trueVal ,
185
- BranchProtectionRule : clients.BranchProtectionRule {
185
+ ProtectionRule : clients.ProtectionRule {
186
186
CheckRules : clients.StatusChecksRule {
187
187
RequiresStatusChecks : & trueVal ,
188
188
UpToDateBeforeMerge : & trueVal ,
@@ -204,7 +204,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
204
204
{
205
205
Name : & rel1 ,
206
206
Protected : & trueVal ,
207
- BranchProtectionRule : clients.BranchProtectionRule {
207
+ ProtectionRule : clients.ProtectionRule {
208
208
CheckRules : clients.StatusChecksRule {
209
209
RequiresStatusChecks : & trueVal ,
210
210
UpToDateBeforeMerge : & falseVal ,
@@ -236,11 +236,11 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
236
236
NumberOfDebug : 0 ,
237
237
},
238
238
defaultBranch : main ,
239
- branches : []* clients.BranchRef {
239
+ branches : []* clients.RepoRef {
240
240
{
241
241
Name : & main ,
242
242
Protected : & trueVal ,
243
- BranchProtectionRule : clients.BranchProtectionRule {
243
+ ProtectionRule : clients.ProtectionRule {
244
244
CheckRules : clients.StatusChecksRule {
245
245
RequiresStatusChecks : & trueVal ,
246
246
UpToDateBeforeMerge : & trueVal ,
@@ -262,7 +262,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
262
262
{
263
263
Name : & rel1 ,
264
264
Protected : & trueVal ,
265
- BranchProtectionRule : clients.BranchProtectionRule {
265
+ ProtectionRule : clients.ProtectionRule {
266
266
CheckRules : clients.StatusChecksRule {
267
267
RequiresStatusChecks : & trueVal ,
268
268
UpToDateBeforeMerge : & trueVal ,
@@ -295,11 +295,11 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
295
295
},
296
296
defaultBranch : main ,
297
297
releases : []string {sha },
298
- branches : []* clients.BranchRef {
298
+ branches : []* clients.RepoRef {
299
299
{
300
300
Name : & main ,
301
301
Protected : & trueVal ,
302
- BranchProtectionRule : clients.BranchProtectionRule {
302
+ ProtectionRule : clients.ProtectionRule {
303
303
CheckRules : clients.StatusChecksRule {
304
304
RequiresStatusChecks : & trueVal ,
305
305
UpToDateBeforeMerge : & falseVal ,
@@ -334,11 +334,11 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
334
334
},
335
335
defaultBranch : main ,
336
336
releases : []string {"" },
337
- branches : []* clients.BranchRef {
337
+ branches : []* clients.RepoRef {
338
338
{
339
339
Name : & main ,
340
340
Protected : & trueVal ,
341
- BranchProtectionRule : clients.BranchProtectionRule {
341
+ ProtectionRule : clients.ProtectionRule {
342
342
CheckRules : clients.StatusChecksRule {
343
343
RequiresStatusChecks : & trueVal ,
344
344
UpToDateBeforeMerge : & falseVal ,
@@ -371,11 +371,11 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
371
371
defaultBranch : main ,
372
372
// branches: []*string{&rel1, &main},
373
373
releases : []string {rel1 },
374
- branches : []* clients.BranchRef {
374
+ branches : []* clients.RepoRef {
375
375
{
376
376
Name : & main ,
377
377
Protected : & trueVal ,
378
- BranchProtectionRule : clients.BranchProtectionRule {
378
+ ProtectionRule : clients.ProtectionRule {
379
379
CheckRules : clients.StatusChecksRule {
380
380
RequiresStatusChecks : & trueVal ,
381
381
UpToDateBeforeMerge : & trueVal ,
@@ -386,7 +386,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
386
386
{
387
387
Name : & rel1 ,
388
388
Protected : & trueVal ,
389
- BranchProtectionRule : clients.BranchProtectionRule {
389
+ ProtectionRule : clients.ProtectionRule {
390
390
CheckRules : clients.StatusChecksRule {
391
391
RequiresStatusChecks : & trueVal ,
392
392
UpToDateBeforeMerge : & trueVal ,
@@ -405,7 +405,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
405
405
ctrl := gomock .NewController (t )
406
406
mockRepoClient := mockrepo .NewMockRepoClient (ctrl )
407
407
mockRepoClient .EXPECT ().GetDefaultBranch ().
408
- DoAndReturn (func () (* clients.BranchRef , error ) {
408
+ DoAndReturn (func () (* clients.RepoRef , error ) {
409
409
defaultBranch := getBranch (tt .branches , tt .defaultBranch , tt .nonadmin )
410
410
return defaultBranch , nil
411
411
}).AnyTimes ()
@@ -420,7 +420,7 @@ func TestReleaseAndDevBranchProtected(t *testing.T) {
420
420
return ret , nil
421
421
}).AnyTimes ()
422
422
mockRepoClient .EXPECT ().GetBranch (gomock .Any ()).
423
- DoAndReturn (func (b string ) (* clients.BranchRef , error ) {
423
+ DoAndReturn (func (b string ) (* clients.RepoRef , error ) {
424
424
return getBranch (tt .branches , b , tt .nonadmin ), nil
425
425
}).AnyTimes ()
426
426
mockRepoClient .EXPECT ().ListFiles (gomock .Any ()).AnyTimes ().Return (tt .repoFiles , nil )
0 commit comments