From 81c3453a543f7d32a5f7104a64ac83066f92d4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 28 Jun 2024 15:32:44 +0200 Subject: [PATCH 1/2] Change GitLab messages to be more consistent with GitHub MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use the same `{icon} {author} {details}` format rather than `{author} {icon} {details}` - Use the same emojis - Emojify the content - For onMergeRequestOpened, add support for draft state and labels Signed-off-by: Kévin Commaille --- src/Connections/GitlabRepo.ts | 43 ++++++++++++++++++++++------------- src/Gitlab/WebhookTypes.ts | 1 + 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/Connections/GitlabRepo.ts b/src/Connections/GitlabRepo.ts index 05e3eb9bf..bb6cf18b4 100644 --- a/src/Connections/GitlabRepo.ts +++ b/src/Connections/GitlabRepo.ts @@ -19,6 +19,8 @@ import { GitLabClient } from "../Gitlab/Client"; import { IBridgeStorageProvider } from "../Stores/StorageProvider"; import axios from "axios"; import { GitLabGrantChecker } from "../Gitlab/GrantChecker"; +import { FormatUtil } from "../FormatUtil"; +import { emojify } from "node-emoji"; export interface GitLabRepoConnectionState extends IConnectionState { instance: string; @@ -558,11 +560,15 @@ export class GitLabRepoConnection extends CommandConnection ({ name: l.title, description: l.description || undefined, color: l.color || undefined }))); await this.intent.sendEvent(this.roomId, { msgtype: "m.notice", - body: content, - formatted_body: md.renderInline(content), + body: content + (labels.plain.length > 0 ? ` with labels ${labels.plain}`: ""), + formatted_body: md.renderInline(content) + (labels.html.length > 0 ? ` with labels ${labels.html}`: ""), format: "org.matrix.custom.html", }); } @@ -574,7 +580,7 @@ export class GitLabRepoConnection extends CommandConnection "); + content += "\n\n> " + emojify(result.commentNotes.join("\n\n> ")); formatted = md.render(content); } else { formatted = md.renderInline(content); diff --git a/src/Gitlab/WebhookTypes.ts b/src/Gitlab/WebhookTypes.ts index ac302e9f9..913a6aa7d 100644 --- a/src/Gitlab/WebhookTypes.ts +++ b/src/Gitlab/WebhookTypes.ts @@ -40,6 +40,7 @@ export interface IGitlabMergeRequest { export interface IGitLabMergeRequestObjectAttributes extends IGitlabMergeRequest { action: "open"|"close"|"reopen"|"approved"|"unapproved"|"merge"; + draft: boolean; } export interface IGitLabLabel { From 46cc4b1276c104492521eb6495db68d8ddc32a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Fri, 28 Jun 2024 17:56:53 +0200 Subject: [PATCH 2/2] Add changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- changelog.d/954.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/954.misc diff --git a/changelog.d/954.misc b/changelog.d/954.misc new file mode 100644 index 000000000..e4369a4e8 --- /dev/null +++ b/changelog.d/954.misc @@ -0,0 +1 @@ +Change GitLab webhook's messages to be more consistent with GitHub webhook's.