README.md in gitlab-triage-0.6.0 vs README.md in gitlab-triage-0.7.0
- old
+ new
@@ -42,11 +42,11 @@
attribute: updated_at
condition: older_than
interval_type: days
interval: 5
state: opened
- label:
+ labels:
- No Label
actions:
labels:
- needs attention
mention:
@@ -87,10 +87,11 @@
- [`labels` condition](#labels-condition)
- [`forbidden_labels` condition](#forbidden-labels-condition)
- [`no_additional_labels` condition](#no-additional-labels-condition)
- [`author_member` condition](#author-member-condition)
- [`assignee_member` condition](#assignee-member-condition)
+- [`ruby` condition](#ruby-condition)
##### Date condition
Accepts a hash of fields.
@@ -175,10 +176,75 @@
conditions:
labels:
- feature proposal
```
+###### Labels over sequences
+
+The name of a label can contain one or more sequence conditions, written
+like `{0..9}`, which means `0`, `1`, `2`, and so on up to `9`. For each
+number, the rule will be duplicated with the new label name.
+
+Example:
+
+```yml
+resource_rules:
+ issues:
+ rules:
+ - name: Add missing ~"missed\-deliverable" label
+ conditions:
+ labels:
+ - missed:{10..11}.{0..1}
+ - deliverable
+ actions:
+ labels:
+ - missed deliverable
+```
+
+Which will be expanded into:
+
+```yml
+resource_rules:
+ issues:
+ rules:
+ - name: Add missing ~"missed\-deliverable" label
+ conditions:
+ labels:
+ - missed:10.0
+ - deliverable
+ actions:
+ labels:
+ - missed deliverable
+
+ - name: Add missing ~"missed\-deliverable" label
+ conditions:
+ labels:
+ - missed:10.1
+ - deliverable
+ actions:
+ labels:
+ - missed deliverable
+
+ - name: Add missing ~"missed\-deliverable" label
+ conditions:
+ labels:
+ - missed:11.0
+ - deliverable
+ actions:
+ labels:
+ - missed deliverable
+
+ - name: Add missing ~"missed\-deliverable" label
+ conditions:
+ labels:
+ - missed:11.1
+ - deliverable
+ actions:
+ labels:
+ - missed deliverable
+```
+
##### Forbidden labels condition
Accepts an array of strings. Each element in the array represents the name of a label to filter on.
> Note: **All** specified labels must be absent on the resource for the condition to be satisfied
@@ -248,9 +314,73 @@
assignee_member:
source: group
condition: not_member_of
source_id: 9970
```
+
+##### Ruby condition
+
+This condition allows users to write a Ruby expression to be evaluated for
+each resource. If it evaluates to a truthy value, it satisfies the condition.
+If it evaluates to a falsey value, it does not satisfy the condition.
+
+Accepts a string as the Ruby expression.
+
+Example:
+
+```yml
+conditions:
+ ruby: Date.today > milestone.succ.start_date
+```
+
+In the above example, this describes that we want to act on the resources
+which passed the next active milestone's starting date.
+
+Here `milestone` will return a `Gitlab::Triage::Resource::Milestone` object,
+representing the milestone of the questioning resource. `Milestone#succ` would
+return the next active milestone, based on the `start_date` of all milestones
+along with the representing milestone. If the milestone was coming from a
+project, then it's based on all active milestones in that project. If the
+milestone was coming from a group, then it's based on all active milestones
+in the group.
+
+If we also want to handle some edge cases, for example, a resource might not
+have a milestone, and a milestone might not be active, and there might not
+have a next milestone. We could instead write something like:
+
+```yml
+conditions:
+ ruby: milestone&.active? && milestone&.succ && Date.today > milestone.succ.start_date
+```
+
+This will make it only act on resources which have active milestones and
+there exists next milestone which has already started.
+
+Here's a list of currently available API:
+
+##### API
+
+| Name | Return type | Description |
+| ---- | ---- | ---- |
+| milestone | Milestone | The milestone attached to the resource |
+
+##### Methods for `Milestone`
+
+| Method | Return type | Description |
+| ---- | ---- | ---- |
+| id | Integer | The id of the milestone |
+| iid | Integer | The iid of the milestone |
+| project_id | Integer | The project id of the milestone if available |
+| group_id | Integer | The group id of the milestone if available |
+| title | String | The title of the milestone |
+| description | String | The description of the milestone |
+| state | String | The state of the milestone. Could be `active` or `closed` |
+| due_date | Date | The due date of the milestone. Could be `nil` |
+| start_date | Date | The start date of the milestone. Could be `nil` |
+| updated_at | Time | The updated timestamp of the milestone |
+| created_at | Time | The created timestamp of the milestone |
+| succ | Milestone | The next active milestone beside this milestone |
+| active? | Boolean | `true` if `state` is `active`; `false` otherwise |
#### Actions field
Used to declare an action to be carried out on a resource if **all** conditions are satisfied.