MCPcopy
hub / github.com/cli/cli / NewCmdEdit

Function NewCmdEdit

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

Source from the content-addressed store, hash-verified

40}
41
42func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Command {
43 opts := &EditOptions{
44 IO: f.IOStreams,
45 HttpClient: f.HttpClient,
46 Surveyor: surveyor{P: f.Prompter},
47 Fetcher: fetcher{},
48 EditorRetriever: editorRetriever{config: f.Config},
49 Prompter: f.Prompter,
50 }
51
52 var bodyFile string
53 var removeMilestone bool
54
55 cmd := &cobra.Command{
56 Use: "edit [<number> | <url> | <branch>]",
57 Short: "Edit a pull request",
58 Long: heredoc.Docf(`
59 Edit a pull request.
60
61 Without an argument, the pull request that belongs to the current branch
62 is selected.
63
64 Editing a pull request's projects requires authorization with the %[1]sproject%[1]s scope.
65 To authorize, run %[1]sgh auth refresh -s project%[1]s.
66
67 The %[1]s--add-assignee%[1]s and %[1]s--remove-assignee%[1]s flags both support
68 the following special values:
69 - %[1]s@me%[1]s: assign or unassign yourself
70 - %[1]s@copilot%[1]s: assign or unassign Copilot (not supported on GitHub Enterprise Server)
71
72 The %[1]s--add-reviewer%[1]s and %[1]s--remove-reviewer%[1]s flags support
73 the following special value:
74 - %[1]s@copilot%[1]s: request or remove review from Copilot (not supported on GitHub Enterprise Server)
75 `, "`"),
76 Example: heredoc.Doc(`
77 # Edit the title and body of a pull request
78 $ gh pr edit 23 --title "I found a bug" --body "Nothing works"
79
80 # Use a file as the body
81 $ gh pr edit 23 --body-file body.txt
82
83 # Manage labels
84 $ gh pr edit 23 --add-label "bug,help wanted" --remove-label "core"
85
86 # Manage reviewers
87 $ gh pr edit 23 --add-reviewer monalisa,hubot --remove-reviewer myorg/team-name
88
89 # Re-request review
90 $ gh pr edit 23 --add-reviewer monalisa
91
92 # Request a review from GitHub Copilot
93 $ gh pr edit 23 --add-reviewer "@copilot"
94
95 # Manage assignees
96 $ gh pr edit 23 --add-assignee "@me" --remove-assignee monalisa,hubot
97
98 # Assign GitHub Copilot
99 $ gh pr edit 23 --add-assignee "@copilot"

Callers 1

TestNewCmdEditFunction · 0.70

Calls 11

NewFinderFunction · 0.92
ParseURLFunction · 0.92
MutuallyExclusiveFunction · 0.92
ReadFileFunction · 0.92
FlagErrorfFunction · 0.92
DirtyMethod · 0.80
CanPromptMethod · 0.80
editRunFunction · 0.70
BaseRepoMethod · 0.65

Tested by 1

TestNewCmdEditFunction · 0.56