Skip to content

Commit dbff7c5

Browse files
authored
Merge pull request #11300 from cli/revert-10547-dan/fix-title-and-body-pr-create-priority
Revert "Fix: `gh pr create` prioritize `--title` and `--body` over `--fill` when `--web` is present"
2 parents 3a53b47 + 1eeb797 commit dbff7c5

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

pkg/cmd/pr/create/create.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,13 @@ func createRun(opts *CreateOptions) error {
388388
return err
389389
}
390390

391-
if opts.TitleProvided {
392-
state.Title = opts.Title
393-
}
394-
395-
if opts.BodyProvided {
396-
state.Body = opts.Body
397-
}
398-
399391
var openURL string
400392

401393
if opts.WebMode {
394+
if !(opts.Autofill || opts.FillFirst) {
395+
state.Title = opts.Title
396+
state.Body = opts.Body
397+
}
402398
if opts.Template != "" {
403399
state.Template = opts.Template
404400
}
@@ -417,6 +413,14 @@ func createRun(opts *CreateOptions) error {
417413
return previewPR(*opts, openURL)
418414
}
419415

416+
if opts.TitleProvided {
417+
state.Title = opts.Title
418+
}
419+
420+
if opts.BodyProvided {
421+
state.Body = opts.Body
422+
}
423+
420424
existingPR, _, err := opts.Finder.Find(shared.FindOptions{
421425
Selector: ctx.PRRefs.QualifiedHeadRef(),
422426
BaseBranch: ctx.PRRefs.BaseRef(),

pkg/cmd/pr/create/create_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,28 +1590,6 @@ func Test_createRun(t *testing.T) {
15901590
},
15911591
expectedOut: "https://github.com/OWNER/REPO/pull/12\n",
15921592
},
1593-
{
1594-
name: "web prioritize title and body over fill",
1595-
setup: func(opts *CreateOptions, t *testing.T) func() {
1596-
opts.WebMode = true
1597-
opts.HeadBranch = "feature"
1598-
opts.TitleProvided = true
1599-
opts.BodyProvided = true
1600-
opts.Title = "my title"
1601-
opts.Body = "my body"
1602-
opts.Autofill = true
1603-
return func() {}
1604-
},
1605-
cmdStubs: func(cs *run.CommandStubber) {
1606-
cs.Register(
1607-
"git -c log.ShowSignature=false log --pretty=format:%H%x00%s%x00%b%x00 --cherry origin/master...feature",
1608-
0,
1609-
"56b6f8bb7c9e3a30093cd17e48934ce354148e80\u0000second commit of pr\u0000\u0000\n"+
1610-
"3a9b48085046d156c5acce8f3b3a0532cd706a4a\u0000first commit of pr\u0000first commit description\u0000\n",
1611-
)
1612-
},
1613-
expectedBrowse: "https://github.com/OWNER/REPO/compare/master...feature?body=my+body&expand=1&title=my+title",
1614-
},
16151593
}
16161594
for _, tt := range tests {
16171595
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)