MCPcopy Create free account
hub / github.com/cli/cli / NewCmdEdit

Function NewCmdEdit

pkg/cmd/pr/edit/edit.go:49–280  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*EditOptions) error)

Source from the content-addressed store, hash-verified

47}
48
49func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Command {
50 opts := &EditOptions{
51 IO: f.IOStreams,
52 HttpClient: f.HttpClient,
53 Config: f.Config,
54 Surveyor: surveyor{P: f.Prompter},
55 Fetcher: fetcher{},
56 EditorRetriever: editorRetriever{config: f.Config},
57 Prompter: f.Prompter,
58 }
59
60 var bodyFile string
61 var removeMilestone bool
62
63 cmd := &cobra.Command{
64 Use: "edit [<number> | <url> | <branch>]",
65 Short: "Edit a pull request",
66 Long: heredoc.Docf(`
67 Edit a pull request.
68
69 Without an argument, the pull request that belongs to the current branch
70 is selected.
71
72 Editing a pull request's projects requires authorization with the %[1]sproject%[1]s scope.
73 To authorize, run %[1]sgh auth refresh -s project%[1]s.
74
75 Use %[1]s--attach%[1]s to upload an image or video. Without a body flag the pull
76 request keeps the body it already has and the attachment is appended to it. If the
77 body references an attached file, such as %[1]s![alt](./login.png)%[1]s, that reference
78 is rewritten to point at the uploaded asset instead.
79 You can attach up to 50 files per command.
80
81 Alt text for an image follows the path after %[1]s#%[1]s, as in
82 %[1]s--attach './login.png#The login error state'%[1]s. Without it the filename is used.
83 A reference already in the body keeps the alt text written there. Video renders
84 as a player and has no alt text, so it cannot be given any.
85
86 If some attachments upload and others fail, the pull request is still updated with the
87 ones that succeeded. The command then exits with a non-zero status, but the pull
88 request's URL is still printed to stdout.
89
90 The %[1]s--add-assignee%[1]s and %[1]s--remove-assignee%[1]s flags both support
91 the following special values:
92 - %[1]s@me%[1]s: assign or unassign yourself
93 - %[1]s@copilot%[1]s: assign or unassign Copilot (not supported on GitHub Enterprise Server)
94
95 The %[1]s--add-reviewer%[1]s and %[1]s--remove-reviewer%[1]s flags support
96 the following special value:
97 - %[1]s@copilot%[1]s: request or remove review from Copilot (not supported on GitHub Enterprise Server)
98 `, "`"),
99 Example: heredoc.Doc(`
100 # Edit the title and body of a pull request
101 $ gh pr edit 23 --title "I found a bug" --body "Nothing works"
102
103 # Use a file as the body
104 $ gh pr edit 23 --body-file body.txt
105
106 # Append a screenshot to the body, with alt text after "#"

Callers 1

TestNewCmdEditFunction · 0.70

Calls 14

NewFinderFunction · 0.92
ParseURLFunction · 0.92
MutuallyExclusiveFunction · 0.92
ReadFileFunction · 0.92
FlagErrorfFunction · 0.92
AddFlagFunction · 0.92
ChangedMethod · 0.80
UserAssetsMethod · 0.80
DirtyMethod · 0.80
CanPromptMethod · 0.80

Tested by 1

TestNewCmdEditFunction · 0.56