Skip to content

Commit

Permalink
chore: update issue support create label (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg authored Nov 1, 2024
1 parent 26a4993 commit 77e16f7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/helper/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export async function doCreateIssue(

export async function doCreateLabel() {
const name = core.getInput('label-name');
const color = core.getInput('label-color') || 'ededed';
const description = core.getInput('label-desc') || '';
const color = core.getInput('label-color');
const description = core.getInput('label-desc');

if (name) {
await ICE.createLabel(name, color, description);
Expand Down
16 changes: 12 additions & 4 deletions src/issue/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ export class IssueCoreEngine implements IIssueCoreEngine {

public async createLabel(
labelName: string,
labelColor: string,
labelDescription: string | undefined,
labelColor: string = 'ededed',
labelDescription: string = '',
) {
const { owner, repo, octokit } = this;
await octokit.issues.createLabel({
Expand Down Expand Up @@ -318,11 +318,19 @@ export class IssueCoreEngine implements IIssueCoreEngine {
state: baseState,
} = issue;

const baseLabelsName = baseLabels.map(({ name }: any) => name);
const baseAssignessName = baseAssigness?.map(({ login }: any) => login);
const baseLabelsName = baseLabels.map(({ name }) => name);
const baseAssignessName = baseAssigness?.map(({ login }) => login);

const newBody = body ? (mode === 'append' ? `${baseBody}\n${body}` : body) : baseBody;

if (labels && labels.length) {
for (const label of labels) {
if (baseLabelsName && baseLabelsName.length && baseLabelsName.indexOf(label) < 0) {
await this.createLabel(label);
}
}
}

await octokit.issues.update({
owner,
repo,
Expand Down
2 changes: 1 addition & 1 deletion src/issue/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface IIssueCoreEngine {
createIssueEmoji: (emoji: TEmoji[]) => Promise<void>;
createLabel: (
labelName: string,
labelColor: string,
labelColor: string | undefined,
labelDescription: string | undefined,
) => Promise<void>;

Expand Down

0 comments on commit 77e16f7

Please sign in to comment.