Add gitlab webhook support
This commit is contained in:
parent
9d41d56e0c
commit
a1ae717c8f
26 changed files with 1824 additions and 8 deletions
20
templates/gitlab/messages/comment.html
Normal file
20
templates/gitlab/messages/comment.html
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
<a data-mautrix-exclude-plaintext href="{{ object_attributes.url }}">
|
||||
{%- if object_attributes.type == CommentType.DISCUSSION_NOTE -%}
|
||||
replied to a thread
|
||||
{%- else -%}
|
||||
commented
|
||||
{%- endif -%}
|
||||
</a> on
|
||||
{% if issue and object_attributes.noteable_type == NoteableType.ISSUE %}
|
||||
{{ issue_link(issue, important=false) }}
|
||||
{% elif merge_request and object_attributes.noteable_type == NoteableType.MERGE_REQUEST %}
|
||||
{{ merge_request_link(merge_request, important=false) }}
|
||||
{% else %}
|
||||
{# unsupported comment target #}
|
||||
{% do abort() %}
|
||||
{% endif %}
|
||||
<br/>
|
||||
{% if object_attributes.description %}
|
||||
<blockquote>{{ object_attributes.description|markdown }}</blockquote>
|
||||
{% endif %}
|
||||
2
templates/gitlab/messages/issue_close.html
Normal file
2
templates/gitlab/messages/issue_close.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
closed {{ issue_link(object_attributes) }}
|
||||
6
templates/gitlab/messages/issue_open.html
Normal file
6
templates/gitlab/messages/issue_open.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
opened {{ issue_link(object_attributes) }}<br/>
|
||||
{% if object_attributes.description %}
|
||||
<blockquote>{{ object_attributes.description|markdown }}</blockquote>
|
||||
{% endif %}
|
||||
{{ fancy_labels(object_attributes.labels) }}
|
||||
2
templates/gitlab/messages/issue_reopen.html
Normal file
2
templates/gitlab/messages/issue_reopen.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
reopened {{ issue_link(object_attributes) }}
|
||||
77
templates/gitlab/messages/issue_update.html
Normal file
77
templates/gitlab/messages/issue_update.html
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
{% if changes.labels %}
|
||||
{{ label_changes(changes.labels.added, changes.labels.removed) }}
|
||||
{{ issue_or_merge_link(object_attributes) }}
|
||||
{# Milestone webhooks don't have the milestone displayname 3:< #}
|
||||
{#{% elif changes.milestone_id %}#}
|
||||
{# {% if not changes.milestone_id.current %}#}
|
||||
{# removed the milestone from {{ issue_or_merge_link(object_attributes) }}#}
|
||||
{# {% else %}#}
|
||||
{# added {{ issue_or_merge_link(object_attributes) }} to milestone#}
|
||||
{# {% endif %}#}
|
||||
{% elif changes.assignees %}
|
||||
{{ assignee_changes(changes.assignees.added, changes.assignees.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) }}
|
||||
{% elif not changes.time_estimate.previous %}
|
||||
set the time estimate of {{ issue_or_merge_link(object_attributes) }} to
|
||||
<strong>{{ util.format_time(changes.time_estimate.current) }}</strong>
|
||||
{% else %}
|
||||
{% if changes.time_estimate.current > changes.time_estimate.previous %}
|
||||
increased
|
||||
{% else %}
|
||||
decreased
|
||||
{% endif %}
|
||||
the time estimate of {{ issue_or_merge_link(object_attributes) }} by
|
||||
<strong>{{ util.format_time(changes.time_estimate.current - changes.time_estimate.previous) }}</strong>
|
||||
{% endif %}
|
||||
{% elif changes.total_time_spent %}
|
||||
{% if not changes.total_time_spent.current %}
|
||||
removed the time spent
|
||||
{% else %}
|
||||
{% if changes.total_time_spent.current > (changes.total_time_spent.previous or 0) %}
|
||||
spent <strong>{{ util.format_time(changes.total_time_spent.current - (changes.total_time_spent.previous or 0)) }}</strong>
|
||||
{% else %}
|
||||
subtracted <strong>{{ util.format_time(changes.total_time_spent.current - changes.total_time_spent.previous) }}</strong>
|
||||
from the time spent
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
on {{ issue_or_merge_link(object_attributes) }}
|
||||
{% elif changes.weight %}
|
||||
{% if not changes.weight.current %}
|
||||
removed
|
||||
{% else %}
|
||||
changed
|
||||
{% endif %}
|
||||
the weight of {{ issue_or_merge_link(object_attributes) }}
|
||||
{% if changes.weight.current %}
|
||||
to <strong>{{ changes.weight.current }}</strong>
|
||||
{% endif %}
|
||||
{% elif changes.due_date %}
|
||||
{% if not changes.due_date.current %}
|
||||
removed the due date of {{ issue_or_merge_link(object_attributes) }}
|
||||
{% else %}
|
||||
set the due date of {{ issue_or_merge_link(object_attributes) }}
|
||||
to <strong>{{ changes.due_date.current.strftime("%B %d, %Y") }}</strong>
|
||||
{% endif %}
|
||||
{% elif changes.confidential %}
|
||||
made {{ issue_or_merge_link(object_attributes) }}
|
||||
{% if changes.confidential.current %}
|
||||
confidential
|
||||
{% else %}
|
||||
non-confidential
|
||||
{% endif %}
|
||||
{% elif changes.discussion_locked %}
|
||||
{% if changes.discussion_locked.current %}
|
||||
locked discussion in
|
||||
{% else %}
|
||||
unlocked discussion in
|
||||
{% endif %}
|
||||
{{ issue_or_merge_link(object_attributes) }}
|
||||
{% elif changes.title %}
|
||||
changed the title of {{ issue_or_merge_link(object_attributes, title=false) }} to {{ changes.title.current }}
|
||||
{% else %}
|
||||
{% do abort() %}
|
||||
{% endif %}
|
||||
9
templates/gitlab/messages/job.html
Normal file
9
templates/gitlab/messages/job.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{% if build_status == BuildStatus.FAILED and not build_allow_failure %}
|
||||
<strong>[<a data-mautrix-exclude-plaintext href="{{ repository.homepage }}">{{ repository.path|e }}</a>]</strong>
|
||||
<a href="{{ build_url }}">Job {{ build_id }}: {{ build_name }}</a>
|
||||
<strong><font color="#ff0000">failed</font></strong>
|
||||
after {{ util.format_time(build_duration) }}
|
||||
(build triggered by {{ user_link(user) }})
|
||||
{% else %}
|
||||
{% do abort() %}
|
||||
{% endif %}
|
||||
11
templates/gitlab/messages/merge_request.html
Normal file
11
templates/gitlab/messages/merge_request.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
{% if action == OPEN %}
|
||||
opened {{ merge_request_link(object_attributes) }}
|
||||
{% if object_attributes.description %}
|
||||
<blockquote>{{ object_attributes.description|markdown }}</blockquote>
|
||||
{% endif %}
|
||||
{{ fancy_labels(labels) }}
|
||||
{% else %}
|
||||
{{ object_attributes.action.past_tense }}
|
||||
{{ merge_request_link(object_attributes) }}
|
||||
{% endif %}
|
||||
27
templates/gitlab/messages/push.html
Normal file
27
templates/gitlab/messages/push.html
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
{% if is_deleted_ref %}
|
||||
deleted branch
|
||||
{% else %}
|
||||
pushed
|
||||
<a href="{{ diff_url }}" data-mautrix-exclude-plaintext>
|
||||
{{- total_commits_count }} commit{{ pluralize(total_commits_count) -}}
|
||||
</a>
|
||||
to
|
||||
{% endif %}
|
||||
<a data-mautrix-exclude-plaintext href="{{ ref_url }}">{{ ref_name }}</a>
|
||||
{%- if is_new_ref %} (new branch){% endif -%}
|
||||
{%- if commits|length > 0 %}:
|
||||
<ul>
|
||||
{% for commit in commits[-5:] %}
|
||||
<li>
|
||||
<code><a data-mautrix-exclude-plaintext href="{{ commit.url }}">
|
||||
{{- commit.id[:8] -}}
|
||||
</a></code>
|
||||
{{ commit.cut_message|e }}
|
||||
{% if commit.author.name != user_name and commit.author.name != user_username %}
|
||||
by {{ commit.author.name }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif -%}
|
||||
13
templates/gitlab/messages/tag.html
Normal file
13
templates/gitlab/messages/tag.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
{% if is_deleted_ref %}
|
||||
deleted tag
|
||||
{{ ref_name }}
|
||||
{% else %}
|
||||
created tag
|
||||
<a data-mautrix-exclude-plaintext href="{{ ref_url }}">{{ ref_name }}</a>
|
||||
{% endif %}
|
||||
{%- if message -%}:
|
||||
<blockquote>
|
||||
{{ message | markdown }}
|
||||
</blockquote>
|
||||
{%- endif -%}
|
||||
1
templates/gitlab/messages/test.html
Normal file
1
templates/gitlab/messages/test.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
5
templates/gitlab/messages/wiki.html
Normal file
5
templates/gitlab/messages/wiki.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{{ templates.repo_sender_prefix }}
|
||||
{{ "edited" if object_attributes.action == UPDATE else object_attributes.action.past_tense }}
|
||||
<a href="{{ object_attributes.url }}">{{ object_attributes.title }}</a>
|
||||
on the wiki
|
||||
{%- if object_attributes.message -%}: {{ object_attributes.message }}{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue