#16099
cli: support attaching files to `but pr new` (like `gh pr create --attach`)
The desktop app and Lite both let you attach images and other files to a PR description (paste, drop, or the attach button). The files are uploaded to gitbutler.com and linked from the body as markdown. but pr new has no way to do this, so from the CLI the only options are hand-hosting an image or editing the PR on the forge afterwards.
gh pr create already has this as --attach, and but could follow the same shape:
but pr new my-branch -m "Fix login" --attach './login.png#The login error state'
but pr new my-branch -F pr.md --attach ./before.png --attach ./after.pngProposed behavior
--attach <FILE[#ALT]>, repeatable, long form only (gh uses-afor--assignee).- Images are appended to the body as
, where alt defaults to the filename. Other files are appended as[name](url), matching what the apps insert. - If the body already references an attached file's path, for example
, that reference is rewritten to the uploaded URL instead of appending a duplicate (as gh does). - Works with every body source:
-m,-F,-t, and the editor. - In a stack, attachments apply only to the selected branch's review, the same way
-mdoes today. - All or nothing: check that every file exists, that each is under the 10 MB upload limit, and that the user is signed in before pushing. If any upload fails, stop before creating the review. gh creates the PR with whichever uploads succeeded; failing early avoids leaving a half-illustrated PR to fix by hand.
- No confirmation prompt: naming the files is the consent. The
--helptext says that uploads are public, since the forge has to be able to load them.
Notes
- The upload itself already exists:
gitbutler_user::api::upload_file(crates/gitbutler-user/src/api.rs), used by the apps throughbut_api::legacy::users::upload_file. No backend changes should be needed. - The CLI has no GitButler sign-in of its own; it uses the account stored by the desktop app or Lite. A signed-out run should fail early and point the user at signing in there. A
but logincommand would be a separate change. - Likely touch points:
crates/but/src/args/forge.rs,crates/but/src/lib.rs,crates/but/src/command/legacy/forge/review.rs, and the skill docs undercrates/but/skill/.
Activity
0No activity yet.