mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00
Automatically add new labels to newly created issues (#292)
* Automatically add new labels to newly created issues * changelog
This commit is contained in:
parent
e8d2003868
commit
1ab442107c
1
changelog.d/292.feature
Normal file
1
changelog.d/292.feature
Normal file
@ -0,0 +1 @@
|
||||
Add new GitHubRepo config option `newIssue.labels` which allows admins to automatically set labels on new issues.
|
@ -34,6 +34,8 @@ This connection supports a few options which can be defined in the room state:
|
||||
|includingLabels|Only notify on issues matching these label names|Array of: String matching a label name|*empty*|
|
||||
|excludingLabels|Never notify on issues matching these label names|Array of: String matching a label name|*empty*|
|
||||
|hotlinkIssues|Send a link to an issue/PR in the room when a user mentions a prefix followed by a number|` { prefix: string }`|`{prefix: "#"}`|
|
||||
|newIssue|Configuration options for new issues|`{ labels: string[] }`|*empty*|
|
||||
|newIssue.labels|Automatically set these labels on issues created via commands|Array of: String matching a label name|*empty*|
|
||||
|
||||
|
||||
### Supported event types
|
||||
|
@ -44,7 +44,10 @@ export interface GitHubRepoConnectionOptions {
|
||||
excludingLabels?: string[];
|
||||
hotlinkIssues?: boolean|{
|
||||
prefix: string;
|
||||
}
|
||||
};
|
||||
newIssue?: {
|
||||
labels: string[];
|
||||
};
|
||||
}
|
||||
export interface GitHubRepoConnectionState extends GitHubRepoConnectionOptions{
|
||||
org: string;
|
||||
@ -438,13 +441,16 @@ export class GitHubRepoConnection extends CommandConnection implements IConnecti
|
||||
if (!octokit) {
|
||||
throw new NotLoggedInError();
|
||||
}
|
||||
const labelsNames = labels?.split(",");
|
||||
const labelsNames = new Set(labels?.split(","));
|
||||
if (this.state.newIssue?.labels) {
|
||||
this.state.newIssue?.labels.forEach(l => labelsNames.add(l));
|
||||
}
|
||||
const res = await octokit.issues.create({
|
||||
repo: this.state.repo,
|
||||
owner: this.state.org,
|
||||
title: title,
|
||||
body: description,
|
||||
labels: labelsNames,
|
||||
labels: [...labelsNames],
|
||||
});
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user