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

Function NewCmdCreate

pkg/cmd/pr/create/create.go:198–416  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*CreateOptions) error)

Source from the content-addressed store, hash-verified

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

Callers 1

TestNewCmdCreateFunction · 0.70

Calls 13

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

Tested by 1

TestNewCmdCreateFunction · 0.56