diff --git a/src/commands/PushCommand.ts b/src/commands/PushCommand.ts index 8bebe0b..4596185 100644 --- a/src/commands/PushCommand.ts +++ b/src/commands/PushCommand.ts @@ -277,6 +277,7 @@ export class PushCommand extends CLICommand { const payload = issueToBugzillaCreate(issue, product, component, originUrl) const bugId = await client.createBug(payload) console.log(`Created bug #${bugId} for issue #${issue.id}`) + await this.reconcileBugStatus(client, bugId, issue) return bugId } catch (err: any) { console.error(`Error creating bug for issue #${issue.id}: ${err.message}`) @@ -330,6 +331,7 @@ export class PushCommand extends CLICommand { const bugId = await client.createBug(payload) bugMap.set(issue.id, bugId) console.log(`Created bug #${bugId} for issue #${issue.id}`) + await this.reconcileBugStatus(client, bugId, issue) } catch (err: any) { console.error(`Error creating bug for issue #${issue.id}: ${err.message}`) } @@ -379,6 +381,23 @@ export class PushCommand extends CLICommand { await client.tagComment(commentId, [`git-${shortHash(commitHash)}`]) } + // Reconcile bug status after creation if issue is not open + private async reconcileBugStatus( + client: BugzillaClient, + bugId: number, + issue: import("../issue.js").Issue + ): Promise { + if (issue.status === "open") return + try { + const bz = statusToBugzilla(issue.status) + const update: Record = { status: bz.status } + if (bz.resolution) update.resolution = bz.resolution + await client.updateBug(bugId, update) + } catch (err: any) { + console.error(`Error reconciling status for bug #${bugId}: ${err.message}`) + } + } + // Format a commit as a markdown Bugzilla comment private formatComment(commit: GitCommit, commitUrl: string): string { const lines: string[] = []