@@ -10,14 +10,7 @@ string defaultBranchTriggerEvent() {
1010 ]
1111}
1212
13- predicate test ( Event e ) {
14- e .getName ( ) = "pull_request_target" and
15- // branches and branches-ignore filters
16- e .hasProperty ( "branches" ) and
17- e .hasProperty ( "branches-ignore" ) and
18- e .getAPropertyValue ( "branches" ) = [ "main" , "master" , "default" ] and
19- not e .getAPropertyValue ( "branches-ignore" ) = [ "main" , "master" , "default" ]
20- }
13+ string defaultBranchNames ( ) { result = [ "main" , "master" , "default" ] }
2114
2215predicate runsOnDefaultBranch ( Job j ) {
2316 exists ( Event e |
@@ -27,7 +20,7 @@ predicate runsOnDefaultBranch(Job j) {
2720 not e .getName ( ) = "pull_request_target"
2821 or
2922 e .getName ( ) = "push" and
30- e .getAPropertyValue ( "branches" ) = [ "main" , "master" , "default" ]
23+ e .getAPropertyValue ( "branches" ) = defaultBranchNames ( )
3124 or
3225 e .getName ( ) = "pull_request_target" and
3326 (
@@ -37,18 +30,18 @@ predicate runsOnDefaultBranch(Job j) {
3730 // only branches-ignore filter
3831 e .hasProperty ( "branches-ignore" ) and
3932 not e .hasProperty ( "branches" ) and
40- not e .getAPropertyValue ( "branches-ignore" ) = [ "main" , "master" , "default" ]
33+ not e .getAPropertyValue ( "branches-ignore" ) = defaultBranchNames ( )
4134 or
4235 // only branches filter
4336 e .hasProperty ( "branches" ) and
4437 not e .hasProperty ( "branches-ignore" ) and
45- e .getAPropertyValue ( "branches" ) = [ "main" , "master" , "default" ]
38+ e .getAPropertyValue ( "branches" ) = defaultBranchNames ( )
4639 or
4740 // branches and branches-ignore filters
4841 e .hasProperty ( "branches" ) and
4942 e .hasProperty ( "branches-ignore" ) and
50- e .getAPropertyValue ( "branches" ) = [ "main" , "master" , "default" ] and
51- not e .getAPropertyValue ( "branches-ignore" ) = [ "main" , "master" , "default" ]
43+ e .getAPropertyValue ( "branches" ) = defaultBranchNames ( ) and
44+ not e .getAPropertyValue ( "branches-ignore" ) = defaultBranchNames ( )
5245 )
5346 )
5447 )
0 commit comments