fix: bound github issue comment views (#915)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
+28
-5
@@ -7,7 +7,7 @@ import { authStatus, prFiles, prList, prRead, prView } from "./auth-pr-read";
|
||||
import { issueBoardAudit } from "./board-audit";
|
||||
import { issueBoardRowAdd, issueBoardRowDelete, issueBoardRowGet, issueBoardRowList, issueBoardRowMove, issueBoardRowUpdate, issueBoardRowUpsert } from "./board-commands";
|
||||
import { authRequired, unsupportedCommand, validationError } from "./client";
|
||||
import { commentDelete, commentPatch, commentUpdate, issueComment, issueState } from "./comments-and-state";
|
||||
import { commentDelete, commentPatch, commentUpdate, commentView, issueComment, issueState } from "./comments-and-state";
|
||||
import { issueScanEscape } from "./escape-scan";
|
||||
import { ghHelp, ghScopedHelp } from "./help";
|
||||
import { issueList } from "./issue-list";
|
||||
@@ -53,13 +53,16 @@ export async function runGhCommand(args: string[]): Promise<GitHubCommandResult
|
||||
return validationError(command, options.repo, "--json field selection is only supported by gh issue read/view/list and gh pr read/view/list");
|
||||
}
|
||||
}
|
||||
if ((optionWasProvided(args, "--raw") || optionWasProvided(args, "--full")) && !((top === "issue" && (isIssueReadCommand(sub) || sub === "list" || sub === "update" || sub === "edit" || sub === "patch")) || top === "preflight" || (top === "pr" && (isPrReadCommand(sub) || sub === "list" || sub === "preflight" || sub === "closeout")))) {
|
||||
const isIssueCommentReadCommand = top === "issue" && sub === "comment" && (third === "view" || third === "read");
|
||||
const isPrCommentReadCommand = top === "pr" && sub === "comment" && (third === "view" || third === "read");
|
||||
if ((optionWasProvided(args, "--raw") || optionWasProvided(args, "--full")) && !((top === "issue" && (isIssueReadCommand(sub) || sub === "list" || sub === "update" || sub === "edit" || sub === "patch")) || isIssueCommentReadCommand || top === "preflight" || (top === "pr" && (isPrReadCommand(sub) || sub === "list" || sub === "preflight" || sub === "closeout")) || isPrCommentReadCommand)) {
|
||||
const command = [top, sub].filter((value): value is string => value !== undefined).join(" ") || "gh";
|
||||
return validationError(command, options.repo, "--raw and --full are explicit full-disclosure aliases only for gh issue list/read/view/update/edit/patch, gh pr list/read/view, and gh pr preflight/closeout.", {
|
||||
return validationError(command, options.repo, "--raw and --full are explicit full-disclosure aliases only for gh issue list/read/view/update/edit/patch/comment view, gh pr list/read/view/comment view, and gh pr preflight/closeout.", {
|
||||
supportedCommands: [
|
||||
"bun scripts/cli.ts gh issue list --repo owner/name --limit 200 --full",
|
||||
"bun scripts/cli.ts gh issue view owner/name#<number> --raw",
|
||||
"bun scripts/cli.ts gh issue view <number> --repo owner/name --json body,title,state,comments",
|
||||
"bun scripts/cli.ts gh issue comment view <commentId> --repo owner/name --full",
|
||||
"bun scripts/cli.ts gh issue update <number> --repo owner/name --body-stdin --full <<'EOF'\n<reviewed body>\nEOF",
|
||||
"bun scripts/cli.ts gh issue patch <number> --repo owner/name --body-patch-stdin --full <<'PATCH'\n*** Begin Patch\n*** Update File: issue.md\n@@\n-old\n+new\n*** End Patch\nPATCH",
|
||||
"bun scripts/cli.ts gh pr list --repo owner/name --limit 100 --full",
|
||||
@@ -226,6 +229,17 @@ export async function runGhCommand(args: string[]): Promise<GitHubCommandResult
|
||||
if (action === "list") return withNumberOptionHint(issueAttachmentList(resolved.repo, token, resolved.number), resolved);
|
||||
return withNumberOptionHint(issueAttachmentDownload(resolved.repo, token, resolved.number, { ...options, repo: resolved.repo }), resolved);
|
||||
}
|
||||
if (sub === "comment" && (third === "view" || third === "read")) {
|
||||
const commandName = `issue comment ${third}`;
|
||||
const resolved = resolvePositionalNumberReference("issue", args, 3, commandName, options);
|
||||
if (isGitHubCommandResult(resolved)) return resolved;
|
||||
const commentId = resolved.number;
|
||||
if (typeof commentId !== "number") return commentId;
|
||||
const { token, probe } = resolveToken(true);
|
||||
const missing = authRequired(resolved.repo, commandName, probe);
|
||||
if (missing !== null || token === null) return missing ?? authRequired(resolved.repo, commandName, { present: false, source: null, ghFallbackAttempted: true });
|
||||
return withNumberOptionHint(commentView(resolved.repo, token, "issue", commentId, options.raw || options.full, commandName), resolved);
|
||||
}
|
||||
if (sub === "comment" && third === "delete") {
|
||||
const resolved = resolvePositionalNumberReference("issue", args, 3, "issue comment delete", options);
|
||||
if (isGitHubCommandResult(resolved)) return resolved;
|
||||
@@ -354,8 +368,8 @@ export async function runGhCommand(args: string[]): Promise<GitHubCommandResult
|
||||
const missing = authRequired(resolved.repo, `issue ${sub}`, probe);
|
||||
if (missing !== null || token === null) return missing ?? authRequired(resolved.repo, `issue ${sub}`, { present: false, source: null, ghFallbackAttempted: true });
|
||||
const disclosure = readDisclosureOptions(options, resolved.shorthand);
|
||||
if (sub === "read") return withNumberOptionHint(issueRead(resolved.repo, token, resolved.number, issueReadJsonFields(options), "issue read", disclosure, { includeFullCommentBodies: options.raw || options.full }), resolved);
|
||||
return withNumberOptionHint(issueView(resolved.repo, token, resolved.number, issueReadJsonFields(options), disclosure, { includeFullCommentBodies: options.raw || options.full }), resolved);
|
||||
if (sub === "read") return withNumberOptionHint(issueRead(resolved.repo, token, resolved.number, issueReadJsonFields(options), "issue read", disclosure, { includeFullCommentBodies: options.raw }), resolved);
|
||||
return withNumberOptionHint(issueView(resolved.repo, token, resolved.number, issueReadJsonFields(options), disclosure, { includeFullCommentBodies: options.raw }), resolved);
|
||||
}
|
||||
const { token, probe } = resolveToken(true);
|
||||
const missing = authRequired(options.repo, `issue ${sub ?? ""}`.trim(), probe);
|
||||
@@ -432,6 +446,15 @@ export async function runGhCommand(args: string[]): Promise<GitHubCommandResult
|
||||
if (missing !== null || token === null) return missing ?? authRequired(resolved.repo, "pr comment delete", { present: false, source: null, ghFallbackAttempted: true });
|
||||
return withNumberOptionHint(commentDelete(resolved.repo, token, "pr", resolved.number, false), resolved);
|
||||
}
|
||||
if (sub === "comment" && (third === "view" || third === "read")) {
|
||||
const commandName = `pr comment ${third}`;
|
||||
const resolved = resolvePositionalNumberReference("pr", args, 3, commandName, options);
|
||||
if (isGitHubCommandResult(resolved)) return resolved;
|
||||
const { token, probe } = resolveToken(true);
|
||||
const missing = authRequired(resolved.repo, commandName, probe);
|
||||
if (missing !== null || token === null) return missing ?? authRequired(resolved.repo, commandName, { present: false, source: null, ghFallbackAttempted: true });
|
||||
return withNumberOptionHint(commentView(resolved.repo, token, "pr", resolved.number, options.raw || options.full, commandName), resolved);
|
||||
}
|
||||
if (sub === "comment" && (third === "update" || third === "edit")) {
|
||||
const commandName = `pr comment ${third}`;
|
||||
const resolved = resolvePositionalNumberReference("pr", args, 3, commandName, options);
|
||||
|
||||
Reference in New Issue
Block a user