fix: reconcile bug status after creation when issue is not open
This commit is contained in:
parent
90efa2494e
commit
d0c2daaeb4
1 changed files with 19 additions and 0 deletions
|
|
@ -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<void> {
|
||||
if (issue.status === "open") return
|
||||
try {
|
||||
const bz = statusToBugzilla(issue.status)
|
||||
const update: Record<string, string> = { 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[] = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue