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

Function NewCmdCreate

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

Source from the content-addressed store, hash-verified

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

Callers 1

TestNewCmdCreateFunction · 0.70

Calls 14

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

Tested by 1

TestNewCmdCreateFunction · 0.56