Skip to content

Commit

Permalink
Add support for reviewer changes in merge requests
Browse files Browse the repository at this point in the history
The merge request event webhook is called for reviwers updates, however
this is ignored by the GitlabChanges class. Therefore these updates are
not forwarded to Matrix. By adding the reviewers section to both the
GitlabChanges and to the issue_update template (which is used for merge
request updates) the bot reports about changes in reviewers.
  • Loading branch information
lordievader committed Jun 5, 2024
1 parent 2cd6d88 commit 7fd23d0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gitlab_matrix/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ class GitlabAssigneeChanges(GitlabChangeWrapper, SerializableAttrs):
current: List[GitlabUser]


@dataclass
class GitlabReviewersChanges(GitlabChangeWrapper, SerializableAttrs):
previous: List[GitlabUser]
current: List[GitlabUser]


@dataclass
class GitlabLabelChanges(GitlabChangeWrapper, SerializableAttrs):
previous: List[GitlabLabel]
Expand Down Expand Up @@ -290,6 +296,7 @@ class GitlabChanges(SerializableAttrs):
title: Optional[GitlabStringChange] = None
labels: Optional[GitlabLabelChanges] = None
assignees: Optional[GitlabAssigneeChanges] = None
reviewers: Optional[GitlabReviewersChanges] = None
time_estimate: Optional[GitlabIntChange] = None
total_time_spent: Optional[GitlabIntChange] = None
weight: Optional[GitlabIntChange] = None
Expand Down
3 changes: 3 additions & 0 deletions templates/macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@
{%- macro assignee_changes(added, removed) -%}
{{ list_changes(added, removed, "assigned", "unassigned", user_link) }}
{%- endmacro -%}
{%- macro reviewers_changes(added, removed) -%}
{{ list_changes(added, removed, "assigned", "unassigned", user_link) }}
{%- endmacro -%}
3 changes: 3 additions & 0 deletions templates/messages/issue_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
{% elif changes.assignees %}
{{ assignee_changes(changes.assignees.added, changes.assignees.removed) }}
{{ issue_or_merge_link(object_attributes) }}
{% elif changes.reviewers %}
{{ reviewers_changes(changes.reviewers.added, changes.reviewers.removed) }}
{{ issue_or_merge_link(object_attributes) }}
{% elif changes.time_estimate %}
{% if not changes.time_estimate.current %}
removed the time estimate of {{ issue_or_merge_link(object_attributes) }}
Expand Down

0 comments on commit 7fd23d0

Please # to comment.