Skip to content

--attach stack 8/8: Add the flag to gh issue create and gh issue edit - #14184

Merged
BagToad merged 2 commits into
bagtoad/attach-pr-commandsfrom
bagtoad/attach-issue-commands
Aug 25, 2026
Merged

--attach stack 8/8: Add the flag to gh issue create and gh issue edit#14184
BagToad merged 2 commits into
bagtoad/attach-pr-commandsfrom
bagtoad/attach-issue-commands

Conversation

@BagToad

@BagToad BagToad commented Aug 18, 2026

Copy link
Copy Markdown
Member

Part of the pull request stack tracked in #14186.

Description

This is the top of the stack. It adds --attach to gh issue create and gh issue edit, one commit each.

gh issue edit 12 --attach ./repro.png

On create the body can come from --body, from --body-file, from standard input, or from a text editor. A reference written in the editor is rewritten exactly like one passed by flag. --attach with --web is refused.

On edit, using only --attach keeps the existing body and appends the file below it, and a reference already in the body is rewritten in place instead.

Editing more than one issue at once with --attach is refused, since one upload would have to be shared across several bodies.

How did you test this change?

Both commands were exercised by hand against a private test repository. That covered an issue created with an image, one created with a video, one created from a body file, and one created through the editor where the reference in the editor text was rewritten in place.

On edit it covered appending to an existing body, and editing where the reference already in the body was rewritten. Both refused flag combinations were checked.

Key points

The editor path is worth knowing about. The body a user types into their editor is treated the same as one passed on the command line, so a reference written there is rewritten too.

Notes for reviewers

With this merged the flag is available on all six commands: gh issue comment, gh pr comment, gh issue create, gh pr create, gh issue edit and gh pr edit.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @BagToad will read and reply directly. Name the account.
  • An agent will draft replies and @BagToad will read them before they are posted.
  • Nobody has explicitly committed to replying.

@BagToad BagToad changed the title bagtoad/attach issue commands --attach stack 8/8: Add the flag to gh issue create and gh issue edit Aug 18, 2026
@BagToad
BagToad marked this pull request as ready for review August 18, 2026 05:56
@BagToad
BagToad requested a review from a team as a code owner August 18, 2026 05:56
@BagToad
BagToad requested review from sergiou87 and a balanced review from Copilot August 18, 2026 05:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds --attach support to issue creation and editing.

Changes:

  • Uploads images/videos and rewrites body references.
  • Rejects incompatible web and multi-issue usage.
  • Adds attachment, permission, host, and failure tests.
Show a summary per file
File Description
pkg/cmd/issue/create/create.go Integrates attachments into issue creation.
pkg/cmd/issue/create/create_test.go Tests creation and upload scenarios.
pkg/cmd/issue/edit/edit.go Integrates attachments into issue editing.
pkg/cmd/issue/edit/edit_test.go Tests editing, uploads, and failures.

Review details

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread pkg/cmd/issue/edit/edit.go
Comment thread pkg/cmd/issue/edit/edit_test.go
Comment thread pkg/cmd/issue/create/create.go
BagToad and others added 2 commits August 18, 2026 14:12
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@BagToad
BagToad force-pushed the bagtoad/attach-issue-commands branch from cf7aa91 to ccd55e6 Compare August 18, 2026 20:20
@BagToad
BagToad requested a review from babakks August 19, 2026 15:51

@babakks babakks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for landing the final piece of the stack, @BagToad! 🎉

This mirrors the pr command work onto gh issue create and gh issue edit, and it's consistent with everything that came before. I confirmed the partial-upload path behaves the same on both: the issue is still created/updated with the attachments that succeeded, the URLs are printed to stdout, and the command exits non-zero. Nice and predictable.

All of my inline notes are non-blocking:

  • Help-text parity nitpicks: document the partial-upload behavior and add a repeated---attach example (no alt text) on both create and edit.
  • A small lament about the named returns in the create run body. Not asking you to change it here, just noting it.
  • The same test-simplification idea from the pr commands: for the "must never prompt" cases we could leave promptStubs nil and rely on the moq panic instead of hand-writing an error stub.

That wraps up the whole 8-PR stack for me. Really nice work carrying this through end to end. 🚀

Comment thread pkg/cmd/issue/create/create.go
Comment thread pkg/cmd/issue/create/create.go
Comment on lines +456 to +458
params["body"] = body
if uploadErr != nil {
defer func() { err = errors.Join(uploadErr, err) }()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we never used named returns in this body of code. Sad.

Comment thread pkg/cmd/issue/create/create_test.go
Comment thread pkg/cmd/issue/edit/edit.go
Comment thread pkg/cmd/issue/edit/edit.go
lmquanacs pushed a commit to lmquanacs/context-builder that referenced this pull request Aug 23, 2026
`index/1` evaluates its argument with `.` bound to its own input, so in
`$excluded | index(.author | ascii_downcase)` the `.author` lookup ran
against the `$excluded` array rather than the comment, aborting every run
with:

    jq: error: Cannot index array with string ("author")

Bind the login before the pipe so the argument no longer depends on `.`.

Verified against cli/cli#14184: 11 comments exported, author excluded,
`--no-bots` correctly trims to 7.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@BagToad
BagToad merged commit cc83172 into trunk Aug 25, 2026
21 checks passed
@BagToad
BagToad deleted the bagtoad/attach-issue-commands branch August 25, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants