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
Copy file name to clipboardexpand all lines: docs/configuration/index.md
+68-123
Original file line number
Diff line number
Diff line change
@@ -2,64 +2,76 @@
2
2
3
3
The default configuration filename is `.scm-engine.yml`, either in current working directory, or if you are in a Git repository, the root of the project.
4
4
5
-
The file path can be changed via `--config` CLI flag and `$SCM_ENGINE_CONFIG_FILE` environment variable.
5
+
The file path can be changed via `--config` CLI flag and `#!css $SCM_ENGINE_CONFIG_FILE` environment variable.
The `#!css label` key is a list of the labels you want to manage.
76
89
77
-
- When using `label.strategy: conditional`
90
+
These keys are shared between the [`#!yaml conditional`](#label.strategy-conditional) and [`#!yaml generate`](#label.strategy-generate) label strategy. (more above these below!)
SCM Engine supports two strategies for managing labels, each changes the behavior of the [`#!css script`](#label.script).
82
95
83
-
**OMITTED** The `name` field must not be set when using the `generate` strategy.
96
+
-`#!yaml conditional` (default, if `#!css strategy` key is omitted), where you provide the `#!css name` of the label, and a [`#!css script`](#label.script) that returns a boolean for wether the label should be added to the Merge Request.
The [`#!css script`](#label.script) must return a `#!yaml boolean` value, where `#!yaml true` mean `add the label` and `#!yaml false` mean `remove the label`.
86
99
87
-
!!! tip
100
+
-`#!yaml generate`, where your `#!css script` generates the list of labels that should be added to the Merge Request.
88
101
89
-
See the [SCM engine expr-lang documentation](#expr-lang-information) for more information about [functions](#functions) and [attributes](#attributes) available.
102
+
The [`#!css script`](#label.script) must return a `list of strings`, where each label returned will be added to the Merge Request.
90
103
91
-
The `script` field is an [expr-lang](https://expr-lang.org/) expression, a safe, fast, and intuitive expression evaluator.
Depending on the `label.strategy` used, the behavior of the script changes, read more about this below.
106
+
Use the `#!yaml conditional` strategy when you want to add/remove a label on a Merge Request depending on *something*. It's the default strategy, and the most simple one to use.
!!! example "Please see the [*Add label if a file extension is modified*](examples.md#add-label-if-a-file-extension-is-modified) example for how to use this"
96
109
97
-
SCM Engine supports two strategies for managing labels, each changes the behavior of the `script`.
-`conditional` (default, if `type` key is omitted), where you provide the `name` of the label, and a `script` that returns a boolean for wether the label should be added to the Merge Request.
112
+
Use the [`#!yaml generate`](#label.strategy) strategy if you want to create dynamic labels, for example, depending labels based on the file structure within your project.
100
113
101
-
The `script` must return a `boolean` value, where `true` mean `add the label` and `false` mean `remove the label`.
114
+
Thanks to the dynamic nature of the `#!yaml generate` strategy, it has fantastic flexibility, at the cost of greater complexity.
102
115
103
-
-`generate`, where your `script` generates the list of labels that should be added to the Merge Request.
116
+
!!! example "Please see the [*generate labels from directory layout*](examples.md#generate-labels-via-script) example for how to use this"
104
117
105
-
The `script` must return a `list of strings`, where each label returned will be added to the Merge Request.
Use the `conditional` strategy when you want to add/remove a label on a Merge Request depending on *something*. It's the default strategy, and the most simple one to use.
122
+
**REQUIRED** The `#!css name` of the label to create.
110
123
111
-
!!! note
124
+
- When using `#!yaml label.strategy: generate`
112
125
113
-
The `script` field is a [expr-lang](https://expr-lang.org/) expression, a safe, fast, and intuitive expression evaluator.
114
-
115
-
```yaml
116
-
label:
117
-
# Add a "lang/go" label if any "*.go" files was changed
118
-
- name: lang/go
119
-
color: "$indigo"
120
-
script: merge_request.modified_files("*.go")
121
-
122
-
# Add a "lang/markdown" label if any "*.md" files was changed
123
-
- name: lang/markdown
124
-
color: "$indigo"
125
-
script: merge_request.modified_files("*.md")
126
-
127
-
# Add a "type/documentation" label if any files was changed within the "docs/" folder
128
-
- name: type/documentation
129
-
color: "$green"
130
-
script: merge_request.modified_files("docs/")
131
-
132
-
# Add a "go::tests" scoped & prioritized label with value "missing" if no "*_test.go" files was changed
133
-
- name: go::tests::missing
134
-
color: "$red"
135
-
priority: 999
136
-
script: not merge_request.modified_files("*_test.go")
137
-
138
-
# Add a "go::tests" scoped & prioritized label with value "OK" if any "*_test.go" files was changed
139
-
- name: go::tests::ok
140
-
color: "$green"
141
-
priority: 999
142
-
script: merge_request.modified_files("*_test.go")
143
-
```
126
+
**OMITTED** The `#!css name` field must not be set when using the `#!yaml generate` strategy.
When used on `strategy: generate` labels, all generated labels will have the same color.
138
+
When used on `#!yaml strategy: generate` labels, all generated labels will have the same color.
192
139
193
-
`color`is a mandatory field, controlling the background color of the label when viewed in the User Interface.
140
+
`#!css color` is a mandatory field, controlling the background color of the label when viewed in the User Interface.
194
141
195
-
You can either provide your own `#hex` value or use the [Twitter Bootstrap color variables](https://getbootstrap.com/docs/5.3/customize/color/#all-colors), for example `$blue-500` and `$teal`.
142
+
You can either provide your own `#!yaml hex` value (e.g, `#FFFF00`) or use the [Twitter Bootstrap color variables](https://getbootstrap.com/docs/5.3/customize/color/#all-colors), for example`#!yaml $blue-500` and `#!yaml $teal`.
An optional key controlling if the label should be skipped (meaning no removal or adding of labels).
160
+
--8<-- "docs/_partials/expr-lang-info.md"
161
+
162
+
!!! tip "The script must return a `boolean` value"
218
163
219
-
The `skip_if` field must be a valid [Expr-lang](https://expr-lang.org/) expression returning a boolean, where `true` means `skip` and `false` means `process`.
164
+
An optional key controlling if the label should be skipped (meaning no removal or adding of labels).
0 commit comments