feat: add heredoc body input to gh cli

This commit is contained in:
Codex
2026-06-06 01:27:52 +00:00
parent 879facb933
commit 0bae3af934
5 changed files with 113 additions and 65 deletions
+13 -3
View File
@@ -684,7 +684,7 @@ export async function runGhCliPrContract(): Promise<JsonRecord> {
const editStdinBody = "stdin line\n`stdin code`\n| c | d |\n";
const beforeEditRequests = mock2.requests.length;
const editStdin = await runCli(["gh", "pr", "edit", "42", "--repo", "pikasTech/unidesk", "--title", "stdin title", "--body-file", "-"], env2, editStdinBody);
const editStdin = await runCli(["gh", "pr", "edit", "42", "--repo", "pikasTech/unidesk", "--title", "stdin title", "--body-stdin"], env2, editStdinBody);
assertCondition(editStdin.status === 0, "pr edit stdin should succeed", editStdin.json ?? { stdout: editStdin.stdout });
const editStdinData = dataOf(editStdin.json ?? {});
assertCondition(editStdinData.command === "pr edit" && editStdinData.pr === 42 && editStdinData.url === "https://github.com/pikasTech/unidesk/pull/42", "pr edit stdin should return low-noise summary", editStdinData);
@@ -720,6 +720,16 @@ export async function runGhCliPrContract(): Promise<JsonRecord> {
const commentCreateData = dataOf(commentCreate.json ?? {});
assertCondition(commentCreateData.command === "pr comment create", "pr comment create should use CRUD command name", commentCreateData);
const prBodyStdinCommentBody = "PR heredoc comment line\n\n- keeps `code`\n";
const prBodyStdinComment = await runCli(["gh", "pr", "comment", "create", "42", "--repo", "pikasTech/unidesk", "--body-stdin"], env2, prBodyStdinCommentBody);
assertCondition(prBodyStdinComment.status === 0, "pr comment create --body-stdin should succeed", prBodyStdinComment.json ?? { stdout: prBodyStdinComment.stdout });
const prBodyStdinCommentData = dataOf(prBodyStdinComment.json ?? {});
const prBodyStdinSource = prBodyStdinCommentData.bodySource as JsonRecord;
assertCondition(prBodyStdinSource.kind === "stdin" && prBodyStdinSource.path === "-", "pr comment create --body-stdin should expose stdin source", prBodyStdinCommentData);
const prBodyStdinRequest = mock2.requests.filter((request) => request.method === "POST" && request.url === "/repos/pikasTech/unidesk/issues/42/comments").at(-1);
const prBodyStdinPayload = JSON.parse(prBodyStdinRequest?.body ?? "{}") as JsonRecord;
assertCondition(prBodyStdinPayload.body === prBodyStdinCommentBody, "pr comment --body-stdin payload should preserve stdin markdown", prBodyStdinPayload);
const prInlineCommentBody = "short PR inline comment remains supported";
const prInlineComment = await runCli(["gh", "pr", "comment", "create", "42", "--repo", "pikasTech/unidesk", "--body", prInlineCommentBody], env2);
assertCondition(prInlineComment.status === 0, "pr comment create --body should remain supported", prInlineComment.json ?? { stdout: prInlineComment.stdout });
@@ -787,9 +797,9 @@ export async function runGhCliPrContract(): Promise<JsonRecord> {
"pr create dry-run exposes planned operation",
"pr comment dry-run preserves markdown text",
"pr update/edit use low-noise REST PATCH without GraphQL projectCards",
"pr edit supports --body-file - stdin without echoing full body",
"pr edit supports --body-stdin without echoing full body",
"pr update append and close/reopen are available",
"pr comment create/delete follows CRUD shape and --body remains supported",
"pr comment create/delete follows CRUD shape, --body-stdin, and --body remains supported",
"pr merge is guarded by preflight and uses REST",
"pr hard delete is blocked",
"pr create validation failures are structured",