@@ -10,14 +10,7 @@ string defaultBranchTriggerEvent() {
10
10
]
11
11
}
12
12
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" ] }
21
14
22
15
predicate runsOnDefaultBranch ( Job j ) {
23
16
exists ( Event e |
@@ -27,7 +20,7 @@ predicate runsOnDefaultBranch(Job j) {
27
20
not e .getName ( ) = "pull_request_target"
28
21
or
29
22
e .getName ( ) = "push" and
30
- e .getAPropertyValue ( "branches" ) = [ "main" , "master" , "default" ]
23
+ e .getAPropertyValue ( "branches" ) = defaultBranchNames ( )
31
24
or
32
25
e .getName ( ) = "pull_request_target" and
33
26
(
@@ -37,18 +30,18 @@ predicate runsOnDefaultBranch(Job j) {
37
30
// only branches-ignore filter
38
31
e .hasProperty ( "branches-ignore" ) and
39
32
not e .hasProperty ( "branches" ) and
40
- not e .getAPropertyValue ( "branches-ignore" ) = [ "main" , "master" , "default" ]
33
+ not e .getAPropertyValue ( "branches-ignore" ) = defaultBranchNames ( )
41
34
or
42
35
// only branches filter
43
36
e .hasProperty ( "branches" ) and
44
37
not e .hasProperty ( "branches-ignore" ) and
45
- e .getAPropertyValue ( "branches" ) = [ "main" , "master" , "default" ]
38
+ e .getAPropertyValue ( "branches" ) = defaultBranchNames ( )
46
39
or
47
40
// branches and branches-ignore filters
48
41
e .hasProperty ( "branches" ) and
49
42
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 ( )
52
45
)
53
46
)
54
47
)
0 commit comments