Skip to content

Commit 47baf8f

Browse files
committed
pr create: explain how to link an issue
1 parent 962791b commit 47baf8f

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

pkg/cmd/pr/create/create.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,23 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
8484
cmd := &cobra.Command{
8585
Use: "create",
8686
Short: "Create a pull request",
87-
Long: heredoc.Doc(`
87+
Long: heredoc.Docf(`
8888
Create a pull request on GitHub.
8989
9090
When the current branch isn't fully pushed to a git remote, a prompt will ask where
91-
to push the branch and offer an option to fork the base repository. Use '--head' to
91+
to push the branch and offer an option to fork the base repository. Use %[1]s--head%[1]s to
9292
explicitly skip any forking or pushing behavior.
9393
94-
A prompt will also ask for the title and the body of the pull request. Use '--title'
95-
and '--body' to skip this, or use '--fill' to autofill these values from git commits.
94+
A prompt will also ask for the title and the body of the pull request. Use %[1]s--title%[1]s
95+
and %[1]s--body%[1]s to skip this, or use %[1]s--fill%[1]s to autofill these values from git commits.
9696
97-
By default users with write access to the base respository can add new commits to your branch.
98-
If undesired, you may disable access of maintainers by using '--no-maintainer-edit'
99-
You can always change this setting later via the web interface.
100-
`),
97+
Link an issue to the pull request by referencing the issue in the body of the pull
98+
request. If the body text mentions %[1]sFixes #123%[1]s or %[1]sCloses #123%[1]s, the referenced issue
99+
will automatically get closed when the pull request gets merged.
100+
101+
By default, users with write access to the base respository can push new commits to the
102+
head branch of the pull request. Disable this with %[1]s--no-maintainer-edit%[1]s.
103+
`, "`"),
101104
Example: heredoc.Doc(`
102105
$ gh pr create --title "The bug is fixed" --body "Everything works again"
103106
$ gh pr create --reviewer monalisa,hubot --reviewer myorg/team-name
@@ -113,21 +116,21 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
113116
opts.MaintainerCanModify = !noMaintainerEdit
114117

115118
if !opts.IO.CanPrompt() && opts.RecoverFile != "" {
116-
return &cmdutil.FlagError{Err: errors.New("--recover only supported when running interactively")}
119+
return &cmdutil.FlagError{Err: errors.New("`--recover` only supported when running interactively")}
117120
}
118121

119122
if !opts.IO.CanPrompt() && !opts.WebMode && !opts.TitleProvided && !opts.Autofill {
120-
return &cmdutil.FlagError{Err: errors.New("--title or --fill required when not running interactively")}
123+
return &cmdutil.FlagError{Err: errors.New("`--title` or `--fill` required when not running interactively")}
121124
}
122125

123126
if opts.IsDraft && opts.WebMode {
124-
return errors.New("the --draft flag is not supported with --web")
127+
return errors.New("the `--draft` flag is not supported with `--web`")
125128
}
126129
if len(opts.Reviewers) > 0 && opts.WebMode {
127-
return errors.New("the --reviewer flag is not supported with --web")
130+
return errors.New("the `--reviewer` flag is not supported with `--web`")
128131
}
129132
if cmd.Flags().Changed("no-maintainer-edit") && opts.WebMode {
130-
return errors.New("the --no-maintainer-edit flag is not supported with --web")
133+
return errors.New("the `--no-maintainer-edit` flag is not supported with `--web`")
131134
}
132135

133136
if runF != nil {

pkg/cmd/pr/create/create_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestPRCreate_nontty_insufficient_flags(t *testing.T) {
120120
defer http.Verify(t)
121121

122122
output, err := runCommand(http, nil, "feature", false, "")
123-
assert.EqualError(t, err, "--title or --fill required when not running interactively")
123+
assert.EqualError(t, err, "`--title` or `--fill` required when not running interactively")
124124

125125
assert.Equal(t, "", output.String())
126126
}

0 commit comments

Comments
 (0)