File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,14 +353,17 @@ var AllRules = func(l *Linter) Rules { //nolint:gocyclo
353353 },
354354 },
355355 {
356- Name : "valid-pipeline-git-checkout-tag" ,
357- Description : "every git-checkout pipeline should have a tag" ,
356+ Name : "valid-pipeline-git-checkout-tag-or-branch " ,
357+ Description : "every git-checkout pipeline should have a tag or branch " ,
358358 Severity : SeverityError ,
359359 LintFunc : func (config config.Configuration ) error {
360360 for _ , p := range config .Pipeline {
361361 if p .Uses == gitCheckout {
362- if _ , ok := p .With ["tag" ]; ! ok {
363- return fmt .Errorf ("tag is missing" )
362+ _ , hasTag := p .With ["tag" ]
363+ _ , hasBranch := p .With ["branch" ]
364+ // "branch" and "tag" are mutually exclusive
365+ if ! hasTag && ! hasBranch {
366+ return fmt .Errorf ("tag or branch is missing" )
364367 }
365368 }
366369 }
Original file line number Diff line number Diff line change @@ -312,17 +312,17 @@ func TestLinter_Rules(t *testing.T) {
312312 matches : 1 ,
313313 },
314314 {
315- file : "wrong-pipeline-git-checkout-tag.yaml" ,
315+ file : "wrong-pipeline-git-checkout-tag-or-branch .yaml" ,
316316 minSeverity : SeverityWarning ,
317317 want : EvalResult {
318- File : "wrong-pipeline-git-checkout-tag" ,
318+ File : "wrong-pipeline-git-checkout-tag-or-branch " ,
319319 Errors : EvalRuleErrors {
320320 {
321321 Rule : Rule {
322- Name : "valid-pipeline-git-checkout-tag" ,
322+ Name : "valid-pipeline-git-checkout-tag-or-branch " ,
323323 Severity : SeverityError ,
324324 },
325- Error : fmt .Errorf ("[valid-pipeline-git-checkout-tag]: tag is missing (ERROR)" ),
325+ Error : fmt .Errorf ("[valid-pipeline-git-checkout-tag-or-branch ]: tag or branch is missing (ERROR)" ),
326326 },
327327 },
328328 },
Original file line number Diff line number Diff line change 11package :
2- name : wrong-pipeline-git-checkout-tag
2+ name : wrong-pipeline-git-checkout-tag-or-branch
33 version : 1.0.0
44 epoch : 0
5- description : " a package with missing pipeline git-checkout tag"
5+ description : " a package with missing pipeline git-checkout tag or branch "
66 copyright :
77 - paths :
88 - " *"
@@ -13,7 +13,6 @@ pipeline:
1313 - uses : git-checkout
1414 with :
1515 repository : https://test.com/missing-copyright/${{package.version}}.tar.gz
16- branch : main
1716 expected-commit : 9c5cfe0525dc7415cec482342ca674875c1e9115
1817update :
1918 enabled : true
You can’t perform that action at this time.
0 commit comments