diff --git a/docs/GITEA_PR_WORKFLOW.md b/docs/GITEA_PR_WORKFLOW.md
index d5a151f..93322fc 100644
--- a/docs/GITEA_PR_WORKFLOW.md
+++ b/docs/GITEA_PR_WORKFLOW.md
@@ -46,6 +46,11 @@ npm run pr:create -- --base --title "
" --body-file
```
The helper checks for an existing open PR with the same base/head and returns it instead of creating a duplicate.
+If the PR body needs to be changed after creation, update it from a body file:
+
+```powershell
+npm run pr:update -- --number --body-file
+```
For stacked work, pass the parent PR branch as ``. For standalone work, pass `main`.
diff --git a/package.json b/package.json
index 8cfa5ef..4ed9852 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"pr:auth": "node scripts/gitea-pr.js auth-check",
"pr:create": "node scripts/gitea-pr.js create",
"pr:view": "node scripts/gitea-pr.js view",
+ "pr:update": "node scripts/gitea-pr.js update",
"pr:merge": "node scripts/gitea-pr.js merge",
"test": "jest --runInBand",
"test:e2e": "npm --prefix frontend run test:e2e --",
diff --git a/scripts/gitea-pr.js b/scripts/gitea-pr.js
index f2091ec..53bb83d 100644
--- a/scripts/gitea-pr.js
+++ b/scripts/gitea-pr.js
@@ -63,12 +63,16 @@ Commands:
view --number
Print basic PR status.
+ update --number [--title ] [--body-file | --body ]
+ Update a PR title/body. Prefer --body-file for multi-line PR bodies.
+
merge --number --yes [--method merge|squash|rebase] [--delete-branch]
Merge a PR. The --yes flag is required to avoid accidental merges.
Examples:
npm run pr:auth
npm run pr:create -- --base feature-custom-store-locations --title "Allow household switcher reordering" --body-file pr-body.md
+ npm run pr:update -- --number 12 --body-file pr-body.md
npm run pr:view -- --number 12
npm run pr:merge -- --number 12 --method merge --delete-branch --yes
`);
@@ -286,6 +290,31 @@ async function viewPull(flags) {
);
}
+async function updatePull(flags) {
+ const number = requiredFlag(flags, "number");
+ const payload = {};
+
+ if (flags.title && flags.title !== true) {
+ payload.title = flags.title;
+ }
+
+ if (flags["body-file"] || typeof flags.body === "string") {
+ payload.body = readBody(flags);
+ }
+
+ if (Object.keys(payload).length === 0) {
+ fail("Nothing to update; pass --title, --body, or --body-file");
+ }
+
+ const pull = await apiRequest(
+ "PATCH",
+ repoRoute(`/pulls/${encodeURIComponent(number)}`),
+ payload
+ );
+
+ console.log(`Updated PR #${pull.number}: ${pull.html_url || pull.url}`);
+}
+
async function mergePull(flags) {
const number = requiredFlag(flags, "number");
if (!flags.yes) {
@@ -334,6 +363,9 @@ async function main() {
case "view":
await viewPull(flags);
break;
+ case "update":
+ await updatePull(flags);
+ break;
case "merge":
await mergePull(flags);
break;