style: update style & changelog

This commit is contained in:
元凛
2023-02-06 21:47:17 +08:00
parent 6a55b3a9f4
commit dbeaa215cb
8 changed files with 168 additions and 162 deletions

View File

@@ -362,6 +362,32 @@ export async function doMarkDuplicate(
}
}
export async function doToggleLabels(labels: string[] = []) {
const issue = await ICE.getIssue();
const baseLabels: string[] = issue.labels.map(({ name }: any) => name);
const addLabels = [];
const removeLabels = [];
for (const label of labels) {
if (baseLabels.includes(label)) {
removeLabels.push(label);
} else {
addLabels.push(label);
}
}
if (removeLabels.length) {
await doRemoveLabels(removeLabels);
}
if (addLabels.length) {
await doAddLabels(addLabels);
}
core.info(`[doToggleLabels] Done!`);
}
export async function doWelcome(
auth: string,
issueNumber: number,
@@ -393,29 +419,3 @@ export async function doWelcome(
core.info(`[doWelcome] ${auth} is not first time!`);
}
}
export async function doToggleLabels(labels: string[] = []) {
const issue = await ICE.getIssue();
const baseLabels: string[] = issue.labels.map(({ name }: any) => name);
const addLabels = [];
const removeLabels = [];
for (const label of labels) {
if (baseLabels.includes(label)) {
removeLabels.push(label);
} else {
addLabels.push(label);
}
}
if (removeLabels.length) {
await doRemoveLabels(removeLabels);
}
if (addLabels.length) {
await doAddLabels(addLabels);
}
core.info(`[doToggleLabels] Done!`);
}

View File

@@ -252,6 +252,10 @@ export class IssueHelperEngine implements IIssueHelperEngine {
await doMarkDuplicate(ctx.payload.comment as TCommentInfo, closeReason, labels, emoji);
break;
}
case 'toggle-labels': {
await doToggleLabels(labels);
break;
}
case 'welcome': {
if (ctx.eventName === 'issues' && ctx.payload.action === 'opened') {
await doWelcome(ctx.actor, issueNumber, body, labels, assignees, emoji);
@@ -260,10 +264,6 @@ export class IssueHelperEngine implements IIssueHelperEngine {
}
break;
}
case 'toggle-labels': {
await doToggleLabels(labels);
break;
}
// -[ Advanced End ]->
default: {
core.warning(`The ${action} is not allowed.`);

View File

@@ -56,6 +56,6 @@ export type TAction =
| 'lock-issues'
| 'mark-assignees'
| 'mark-duplicate'
| 'welcome'
| 'toggle-labels';
| 'toggle-labels'
| 'welcome';
//// [ Advanced End ]