You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* yasu/branch-filter:
rule: use keyword "any" for global filter override
docs: s/if absent/default/
test: use filter_main_branch in test config
rule: use main_branch_name for global filtering
docs: clean up prefix rule fields table
docs: info about branch filter
tests: add cases for local+default branch filter
rule: distinguish undeclared vs empty local filter
rule: add global `default_branch_filters`
rule: add `branch_filters` prefix rule
|`main_branch_name`| main branch used for the repo; filtering notifications about merges of main into other branches | Yes | - |
32
+
|`main_branch_name`| main branch used for the repo; filtering notifications about merges of main into other branches, and constraining prefix rule application| Yes | - |
33
33
|`label_rules`| label rules config object | No | - |
34
34
|`prefix_rules`| prefix rules config object | No | - |
35
35
|`status_rules`| status rules config object | No | - |
@@ -97,6 +97,7 @@ A **label rule** specifies whether or not a Slack channel should be notified, ba
97
97
```json
98
98
"prefix_rules": {
99
99
"default_channel": "default",
100
+
"filter_main_branch": true,
100
101
"rules": [
101
102
{
102
103
"match": [
@@ -109,6 +110,7 @@ A **label rule** specifies whether or not a Slack channel should be notified, ba
109
110
"backend/megaindex",
110
111
"backend/ahrefskit"
111
112
],
113
+
"branch_filters": "any",
112
114
"channel": "backend"
113
115
},
114
116
{
@@ -117,16 +119,27 @@ A **label rule** specifies whether or not a Slack channel should be notified, ba
117
119
]
118
120
},
119
121
```
122
+
| value | description | default |
123
+
|-|-|-|
124
+
|`default_channel`| same behavior as label rule `default_channel`||
125
+
|`filter_main_branch`| if true and `main_branch_name` is declared, use main branch to filter rules that have no local filter; otherwise, don't apply branch filtering and show `distinct` commits only | false |
126
+
|`rules`| list of `prefix_rule` objects | required field |
120
127
121
128
### Prefix Rule
122
129
123
130
A **prefix rule** specifies whether or not a Slack channel should be notified, based on the filenames present in the commits associated with the given payload. The semantics for the `match` and `ignore` fields are the same as those for label rules (see above).
124
131
125
-
| value | description | optional | default |
126
-
|-|-|-|-|
127
-
|`match`| if commit files have any prefix in this list, they should be routed to the channel | Yes | all prefixes matched if no list provided |
128
-
|`ignore`| if commit files have any prefix in this list, they shouldn't be routed to the channel (even if they have any `match` prefixes) | Yes | - |
129
-
|`channel`| channel to notify if the rule is matched | No | - |
132
+
Default behavior is to apply each rule regardless of what branch is pushed, and when a rule is matched, show its `distinct` commits only.
133
+
Branch filters limit rule application to selected branches, and shows _all_ commits on match.
134
+
The filters can be declared globally with `filter_main_branch` (see above), or locally per rule with `branch_filters`, where the latter takes precedence.
135
+
To ignore a globally declared filter for a single rule, declare one locally with value "any", as shown in the example above.
136
+
137
+
| value | description | default |
138
+
|-|-|-|
139
+
|`match`| if commit files have any prefix in this list, they should be routed to the channel | all prefixes matched |
140
+
|`ignore`| if commit files have any prefix in this list, they shouldn't be routed to the channel (even if they have any `match` prefixes) | fall back on `match` field behavior |
141
+
|`branch_filters`| consider commits only if pushed ref branch is in this list; set to "any" to ignore `filter_main_branch` for this rule | fall back on `filter_main_branch` field behavior (see above) |
142
+
|`channel`| channel to notify if the rule is matched | required field |
0 commit comments