Add support for mentioning multiple assignees on GitHub issues (#889)

* Add support for multiple assignees on issues

* changelog
This commit is contained in:
Will Hunt 2024-02-06 11:09:21 +01:00 committed by GitHub
parent ee7e3ff03f
commit 90927a71f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

1
changelog.d/889.feature Normal file
View File

@ -0,0 +1 @@
Mention all assignees when a new issue is created on GitHub.

View File

@ -887,7 +887,7 @@ export class GitHubRepoConnection extends CommandConnection<GitHubRepoConnection
const icon = '📥';
let message = emojify(`${icon} **${event.issue.user.login}** created new issue [${orgRepoName}#${event.issue.number}](${event.issue.html_url}): "${event.issue.title}"`);
message += (event.issue.assignee ? ` assigned to ${event.issue.assignee.login}` : '');
message += (event.issue.assignees.length ? ` assigned to ${event.issue.assignees.map(a => a.login).join(', ')}` : '');
if (this.showIssueRoomLink) {
const appInstance = await this.githubInstance.getSafeOctokitForRepo(this.org, this.repo);
if (appInstance) {

View File

@ -6,6 +6,7 @@ import { DefaultConfig } from "../../src/config/Defaults";
import { AppserviceMock } from "../utils/AppserviceMock";
import { ApiError, ErrCode, ValidatorApiError } from "../../src/api";
import { expect } from "chai";
import { IntentMock } from "../utils/IntentMock";
const ROOM_ID = "!foo:bar";
@ -58,7 +59,7 @@ function createConnection(state: Record<string, unknown> = {}, isExistingState=f
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
DefaultConfig.github!
);
return {connection, intent};
return {connection, intent: intent as IntentMock};
}
describe("GitHubRepoConnection", () => {
@ -136,6 +137,21 @@ describe("GitHubRepoConnection", () => {
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.html_url, 0);
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.title, 0);
});
it.only("will handle assignees on issue creation", async () => {
const { connection, intent } = createConnection();
await connection.onIssueCreated({
...GITHUB_ISSUE_CREATED_PAYLOAD,
issue: {
...GITHUB_ISSUE,
assignees: [{ login: 'alice'}, { login: 'bob'}]
}
} as never);
// Statement text.
intent.expectEventBodyContains('**alice** created new issue', 0);
intent.expectEventBodyContains('"My issue" assigned to alice, bob', 0);
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.html_url, 0);
intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.title, 0);
});
it("will filter out issues not matching includingLabels.", async () => {
const { connection, intent } = createConnection({
includingLabels: ["include-me"]