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

Function NewCmdEdit

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

Source from the content-addressed store, hash-verified

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

Tested by 1

TestNewCmdEditFunction · 0.56