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

Function NewCmdEdit

pkg/cmd/pr/edit/edit.go:50–283  ·  view source on GitHub ↗
(f *cmdutil.Factory, telemetry ghtelemetry.CommandRecorder, runF func(*EditOptions) error)

Source from the content-addressed store, hash-verified

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

Callers 1

TestNewCmdEditFunction · 0.70

Calls 15

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

Tested by 1

TestNewCmdEditFunction · 0.56