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