| 192 | } |
| 193 | |
| 194 | func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Command { |
| 195 | opts := &CreateOptions{ |
| 196 | IO: f.IOStreams, |
| 197 | HttpClient: f.HttpClient, |
| 198 | GitClient: f.GitClient, |
| 199 | Config: f.Config, |
| 200 | Remotes: f.Remotes, |
| 201 | Branch: f.Branch, |
| 202 | Browser: f.Browser, |
| 203 | Prompter: f.Prompter, |
| 204 | TitledEditSurvey: shared.TitledEditSurvey(&shared.UserEditor{Config: f.Config, IO: f.IOStreams}), |
| 205 | } |
| 206 | |
| 207 | var bodyFile string |
| 208 | |
| 209 | cmd := &cobra.Command{ |
| 210 | Use: "create", |
| 211 | Short: "Create a pull request", |
| 212 | Long: heredoc.Docf(` |
| 213 | Create a pull request on GitHub. |
| 214 | |
| 215 | Upon success, the URL of the created pull request will be printed. |
| 216 | |
| 217 | When the current branch isn't fully pushed to a git remote, a prompt will ask where |
| 218 | to push the branch and offer an option to fork the base repository. Any fork created this |
| 219 | way will only have the default branch of the upstream repository. Use %[1]s--head%[1]s to |
| 220 | explicitly skip any forking or pushing behavior. |
| 221 | |
| 222 | %[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. |
| 223 | Using an organization as the %[1]s<user>%[1]s is currently not supported. |
| 224 | For more information, see <https://github.com/cli/cli/issues/10093> |
| 225 | |
| 226 | A prompt will also ask for the title and the body of the pull request. Use %[1]s--title%[1]s and |
| 227 | %[1]s--body%[1]s to skip this, or use %[1]s--fill%[1]s to autofill these values from git commits. |
| 228 | It's important to notice that if the %[1]s--title%[1]s and/or %[1]s--body%[1]s are also provided |
| 229 | alongside %[1]s--fill%[1]s, the values specified by %[1]s--title%[1]s and/or %[1]s--body%[1]s will |
| 230 | take precedence and overwrite any autofilled content. |
| 231 | |
| 232 | The base branch for the created PR can be specified using the %[1]s--base%[1]s flag. If not provided, |
| 233 | the value of %[1]sgh-merge-base%[1]s git branch config will be used. If not configured, the repository's |
| 234 | default branch will be used. Run %[1]sgit config branch.{current}.gh-merge-base {base}%[1]s to configure |
| 235 | the current branch to use the specified merge base. |
| 236 | |
| 237 | Link an issue to the pull request by referencing the issue in the body of the pull |
| 238 | request. If the body text mentions %[1]sFixes #123%[1]s or %[1]sCloses #123%[1]s, the referenced issue |
| 239 | will automatically get closed when the pull request gets merged. |
| 240 | |
| 241 | By default, users with write access to the base repository can push new commits to the |
| 242 | head branch of the pull request. Disable this with %[1]s--no-maintainer-edit%[1]s. |
| 243 | |
| 244 | Adding a pull request to projects requires authorization with the %[1]sproject%[1]s scope. |
| 245 | To authorize, run %[1]sgh auth refresh -s project%[1]s. |
| 246 | `, "`"), |
| 247 | Example: heredoc.Doc(` |
| 248 | $ gh pr create --title "The bug is fixed" --body "Everything works again" |
| 249 | $ gh pr create --reviewer monalisa,hubot --reviewer myorg/team-name |
| 250 | $ gh pr create --project "Roadmap" |
| 251 | $ gh pr create --base develop --head monalisa:feature |