@kody-ade/kody-engine-lite 0.1.43 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +47 -5
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -515,6 +515,32 @@ function postComment(issueNumber, body) {
|
|
|
515
515
|
logger.warn(` Failed to post comment: ${err}`);
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
+
function getPRForBranch(branch) {
|
|
519
|
+
try {
|
|
520
|
+
const output = gh([
|
|
521
|
+
"pr",
|
|
522
|
+
"view",
|
|
523
|
+
branch,
|
|
524
|
+
"--json",
|
|
525
|
+
"number,url"
|
|
526
|
+
]);
|
|
527
|
+
const data = JSON.parse(output);
|
|
528
|
+
return { number: data.number, url: data.url };
|
|
529
|
+
} catch {
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
function updatePR(prNumber, body) {
|
|
534
|
+
try {
|
|
535
|
+
gh(
|
|
536
|
+
["pr", "edit", String(prNumber), "--body-file", "-"],
|
|
537
|
+
{ input: body }
|
|
538
|
+
);
|
|
539
|
+
logger.info(` PR #${prNumber} body updated`);
|
|
540
|
+
} catch (err) {
|
|
541
|
+
logger.warn(` Failed to update PR #${prNumber}: ${err}`);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
518
544
|
function createPR(head, base, title, body) {
|
|
519
545
|
try {
|
|
520
546
|
const output = gh(
|
|
@@ -1520,21 +1546,37 @@ function executeShipStage(ctx, _def) {
|
|
|
1520
1546
|
}
|
|
1521
1547
|
}
|
|
1522
1548
|
const body = buildPrBody(ctx);
|
|
1523
|
-
const
|
|
1524
|
-
if (
|
|
1549
|
+
const existingPr = getPRForBranch(head);
|
|
1550
|
+
if (existingPr) {
|
|
1551
|
+
updatePR(existingPr.number, body);
|
|
1525
1552
|
if (ctx.input.issueNumber && !ctx.input.local) {
|
|
1526
1553
|
try {
|
|
1527
|
-
postComment(ctx.input.issueNumber, `\
|
|
1554
|
+
postComment(ctx.input.issueNumber, `\u2705 Fix pushed to existing PR: ${existingPr.url}`);
|
|
1528
1555
|
} catch {
|
|
1529
1556
|
}
|
|
1530
1557
|
}
|
|
1531
1558
|
fs9.writeFileSync(shipPath, `# Ship
|
|
1532
1559
|
|
|
1560
|
+
Updated existing PR: ${existingPr.url}
|
|
1561
|
+
PR #${existingPr.number}
|
|
1562
|
+
`);
|
|
1563
|
+
} else {
|
|
1564
|
+
const pr = createPR(head, base, title, body);
|
|
1565
|
+
if (pr) {
|
|
1566
|
+
if (ctx.input.issueNumber && !ctx.input.local) {
|
|
1567
|
+
try {
|
|
1568
|
+
postComment(ctx.input.issueNumber, `\u{1F389} PR created: ${pr.url}`);
|
|
1569
|
+
} catch {
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
fs9.writeFileSync(shipPath, `# Ship
|
|
1573
|
+
|
|
1533
1574
|
PR created: ${pr.url}
|
|
1534
1575
|
PR #${pr.number}
|
|
1535
1576
|
`);
|
|
1536
|
-
|
|
1537
|
-
|
|
1577
|
+
} else {
|
|
1578
|
+
fs9.writeFileSync(shipPath, "# Ship\n\nPushed branch but failed to create PR.\n");
|
|
1579
|
+
}
|
|
1538
1580
|
}
|
|
1539
1581
|
return { outcome: "completed", outputFile: "ship.md", retries: 0 };
|
|
1540
1582
|
} catch (err) {
|