74 lines
2.4 KiB
JavaScript
74 lines
2.4 KiB
JavaScript
// Status mapping: TODO → Bugzilla
|
|
const STATUS_TO_BZ = {
|
|
"open": { status: "CONFIRMED" },
|
|
"in-progress": { status: "IN_PROGRESS" },
|
|
"done": { status: "RESOLVED", resolution: "FIXED" },
|
|
"hold": { status: "RESOLVED", resolution: "LATER" },
|
|
"cancelled": { status: "RESOLVED", resolution: "WONTFIX" },
|
|
};
|
|
// Priority mapping
|
|
const PRIORITY_TO_BZ = {
|
|
"low": "Low",
|
|
"medium": "Normal",
|
|
"high": "Highest",
|
|
};
|
|
// Type → Severity mapping
|
|
const TYPE_TO_SEVERITY = {
|
|
"feature": "enhancement",
|
|
"bugfix": "normal",
|
|
"hotfix": "critical",
|
|
};
|
|
export function statusToBugzilla(status) {
|
|
return STATUS_TO_BZ[status] ?? { status: "NEW" };
|
|
}
|
|
export function priorityToBugzilla(priority) {
|
|
return PRIORITY_TO_BZ[priority] ?? "Normal";
|
|
}
|
|
export function typeToBugzilla(type) {
|
|
return TYPE_TO_SEVERITY[type] ?? "normal";
|
|
}
|
|
export function resolveProductComponent(issue, bugzilla) {
|
|
if (!bugzilla)
|
|
return null;
|
|
if (issue.module) {
|
|
const mapping = bugzilla.mappings.find((m) => m.module === issue.module);
|
|
if (mapping)
|
|
return { product: mapping.product, component: mapping.component };
|
|
}
|
|
// Fall back to first mapping
|
|
return bugzilla.mappings.length > 0
|
|
? { product: bugzilla.mappings[0].product, component: bugzilla.mappings[0].component }
|
|
: null;
|
|
}
|
|
export function issueToBugzillaCreate(issue, product, component, url) {
|
|
const bz = statusToBugzilla(issue.status);
|
|
return {
|
|
product,
|
|
component,
|
|
version: "unspecified",
|
|
summary: issue.title,
|
|
url,
|
|
description: issue.description || undefined,
|
|
priority: priorityToBugzilla(issue.priority),
|
|
severity: typeToBugzilla(issue.type),
|
|
op_sys: "All",
|
|
rep_platform: "All",
|
|
depends_on: issue.relationships.dependsOn ?? [],
|
|
blocks: issue.relationships.blocks ?? [],
|
|
see_also: (issue.relationships.relatesTo ?? []).map(String),
|
|
};
|
|
}
|
|
export function issueToBugzillaUpdate(issue) {
|
|
const bz = statusToBugzilla(issue.status);
|
|
const payload = {
|
|
summary: issue.title,
|
|
status: bz.status,
|
|
priority: priorityToBugzilla(issue.priority),
|
|
severity: typeToBugzilla(issue.type),
|
|
depends_on: { set: issue.relationships.dependsOn ?? [] },
|
|
blocks: { set: issue.relationships.blocks ?? [] },
|
|
};
|
|
if (bz.resolution)
|
|
payload.resolution = bz.resolution;
|
|
return payload;
|
|
}
|