mirror of
https://gitea.com/Lydanne/issues-helper.git
synced 2025-08-19 18:25:58 +08:00
style: update style & changelog
This commit is contained in:
@@ -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!`);
|
||||
}
|
||||
|
@@ -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.`);
|
||||
|
@@ -56,6 +56,6 @@ export type TAction =
|
||||
| 'lock-issues'
|
||||
| 'mark-assignees'
|
||||
| 'mark-duplicate'
|
||||
| 'welcome'
|
||||
| 'toggle-labels';
|
||||
| 'toggle-labels'
|
||||
| 'welcome';
|
||||
//// [ Advanced End ]
|
||||
|
Reference in New Issue
Block a user