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

Function NewCmdCreate

pkg/cmd/pr/create/create.go:201–420  ·  view source on GitHub ↗
(f *cmdutil.Factory, telemetry ghtelemetry.InvocationRecorder, runF func(*CreateOptions) error)

Source from the content-addressed store, hash-verified

199}
200
201func NewCmdCreate(f *cmdutil.Factory, telemetry ghtelemetry.InvocationRecorder, runF func(*CreateOptions) error) *cobra.Command {
202 opts := &CreateOptions{
203 IO: f.IOStreams,
204 HttpClient: f.HttpClient,
205 GitClient: f.GitClient,
206 Config: f.Config,
207 Remotes: f.Remotes,
208 Branch: f.Branch,
209 Browser: f.Browser,
210 Prompter: f.Prompter,
211 TitledEditSurvey: shared.TitledEditSurvey(&shared.UserEditor{Config: f.Config, IO: f.IOStreams}),
212 }
213
214 var bodyFile string
215
216 cmd := &cobra.Command{
217 Use: "create",
218 Short: "Create a pull request",
219 Long: heredoc.Docf(`
220 Create a pull request on GitHub.
221
222 Upon success, the URL of the created pull request will be printed.
223
224 When the current branch isn't fully pushed to a git remote, a prompt will ask where
225 to push the branch and offer an option to fork the base repository. Any fork created this
226 way will only have the default branch of the upstream repository. Use %[1]s--head%[1]s to
227 explicitly skip any forking or pushing behavior.
228
229 %[1]s--head%[1]s supports %[1]s<user>:<branch>%[1]s syntax to select a head repo owned by %[1]s<user>%[1]s.
230 Using an organization as the %[1]s<user>%[1]s is currently not supported.
231 For more information, see <https://github.com/cli/cli/issues/10093>
232
233 A prompt will also ask for the title and the body of the pull request. Use %[1]s--title%[1]s and
234 %[1]s--body%[1]s to skip this, or use %[1]s--fill%[1]s to autofill these values from git commits.
235 It's important to notice that if the %[1]s--title%[1]s and/or %[1]s--body%[1]s are also provided
236 alongside %[1]s--fill%[1]s, the values specified by %[1]s--title%[1]s and/or %[1]s--body%[1]s will
237 take precedence and overwrite any autofilled content.
238
239 The base branch for the created PR can be specified using the %[1]s--base%[1]s flag. If not provided,
240 the value of %[1]sgh-merge-base%[1]s git branch config will be used. If not configured, the repository's
241 default branch will be used. Run %[1]sgit config branch.{current}.gh-merge-base {base}%[1]s to configure
242 the current branch to use the specified merge base.
243
244 Link an issue to the pull request by referencing the issue in the body of the pull
245 request. If the body text mentions %[1]sFixes #123%[1]s or %[1]sCloses #123%[1]s, the referenced issue
246 will automatically get closed when the pull request gets merged.
247
248 Use %[1]s--attach%[1]s to upload an image or video. The attachment is appended to the
249 body. If the body references an attached file, such as %[1]s![alt](./login.png)%[1]s, that
250 reference is rewritten to point at the uploaded asset instead.
251 You can attach up to 50 files per command.
252
253 Alt text for an image follows the path after %[1]s#%[1]s, as in
254 %[1]s--attach './login.png#The login error state'%[1]s. Without it the filename is used.
255 A reference already in the body keeps the alt text written there. Video renders
256 as a player and has no alt text, so it cannot be given any.
257
258 If some attachments upload and others fail, the pull request is still created with the

Callers 1

TestNewCmdCreateFunction · 0.70

Calls 15

TitledEditSurveyFunction · 0.92
NewFinderFunction · 0.92
FlagErrorfFunction · 0.92
MutuallyExclusiveFunction · 0.92
InitEditorModeFunction · 0.92
ReadFileFunction · 0.92
BeginTelemetryFunction · 0.92
AddFlagFunction · 0.92
ChangedMethod · 0.80
CanPromptMethod · 0.80

Tested by 1

TestNewCmdCreateFunction · 0.56