--attach stack 8/8: Add the flag to gh issue create and gh issue edit - #14184
Conversation
--attach stack 8/8: Add the flag to gh issue create and gh issue edit
There was a problem hiding this comment.
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
16e8fbe to
cf7aa91
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
cf7aa91 to
ccd55e6
Compare
babakks
left a comment
There was a problem hiding this comment.
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-
--attachexample (no alt text) on bothcreateandedit. - 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
promptStubsnil 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. 🚀
| params["body"] = body | ||
| if uploadErr != nil { | ||
| defer func() { err = errors.Join(uploadErr, err) }() |
There was a problem hiding this comment.
I wish we never used named returns in this body of code. Sad.
`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>
Part of the pull request stack tracked in #14186.
Description
This is the top of the stack. It adds
--attachtogh issue createandgh issue edit, one commit each.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.--attachwith--webis refused.On edit, using only
--attachkeeps 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
--attachis 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 editandgh pr edit.Authorship and follow-up
Who wrote this:
Who answers review comments: