From 5f34bc900c9a19c0d3229440536b7ea8af14e8e3 Mon Sep 17 00:00:00 2001 From: Rainer Killinger Date: Fri, 30 Oct 2020 17:18:31 +0100 Subject: [PATCH] refactor: omit assigne self reference --- src/tasks/remind.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/tasks/remind.ts b/src/tasks/remind.ts index ac1dce5f..790be9c1 100644 --- a/src/tasks/remind.ts +++ b/src/tasks/remind.ts @@ -115,6 +115,10 @@ export async function remind(api: Api): Promise { // get possible appropers, prefixed with '@' and joined with commas const possibleApprovers = maintainerUsernames .filter((username) => { + if (mergeRequest.assignee.username === username) { + return false; + } + if (approval.approved_by.length === 0) { return true; } @@ -133,8 +137,8 @@ export async function remind(api: Api): Promise { // send message to slack await client.chat.postMessage({ - channel: SLACK_CHANNEL, - text: `Merge request '${mergeRequest.title}' needs more approvals! See ${mergeRequest.web_url}!`, + channel: SLACK_CHANNEL, + text: `Merge request '${mergeRequest.title}' needs more approvals! See ${mergeRequest.web_url}!`, }); // create note in merge request @@ -149,12 +153,15 @@ export async function remind(api: Api): Promise { // send message to slack await client.chat.postMessage({ - channel: SLACK_CHANNEL, - text: `Merge request '${mergeRequest.title}' is ready to be merged! See ${mergeRequest.web_url}!`, + channel: SLACK_CHANNEL, + text: `Merge request '${mergeRequest.title}' is ready to be merged! See ${mergeRequest.web_url}!`, }); // prefix maintainers with '@' and join with commas const possibleMergers = maintainerUsernames + .filter((username) => { + return mergeRequest.assignee.username !== username; + }) .map((username) => `@${username}`) .join(', ');