Merge pull request #9863 from nilvng/nil/fix-7804
fix: `gh pr create -w` ignore template flag
This commit is contained in:
commit
215e4f440f
4 changed files with 23 additions and 0 deletions
|
|
@ -278,6 +278,9 @@ func createRun(opts *CreateOptions) (err error) {
|
|||
state.Title = opts.Title
|
||||
state.Body = opts.Body
|
||||
}
|
||||
if opts.Template != "" {
|
||||
state.Template = opts.Template
|
||||
}
|
||||
err = handlePush(*opts, *ctx)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -1714,6 +1714,19 @@ func Test_generateCompareURL(t *testing.T) {
|
|||
want: "https://github.com/OWNER/REPO/compare/main%2Ftrunk...owner:%21$&%27%28%29+%2C%3B=@?body=&expand=1",
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "with template",
|
||||
ctx: CreateContext{
|
||||
BaseRepo: api.InitRepoHostname(&api.Repository{Name: "REPO", Owner: api.RepositoryOwner{Login: "OWNER"}}, "github.com"),
|
||||
BaseBranch: "main",
|
||||
HeadBranchLabel: "feature",
|
||||
},
|
||||
state: shared.IssueMetadataState{
|
||||
Template: "story.md",
|
||||
},
|
||||
want: "https://github.com/OWNER/REPO/compare/main...feature?body=&expand=1&template=story.md",
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ func WithPrAndIssueQueryParams(client *api.Client, baseRepo ghrepo.Interface, ba
|
|||
if len(state.Assignees) > 0 {
|
||||
q.Set("assignees", strings.Join(state.Assignees, ","))
|
||||
}
|
||||
// Set a template parameter if no body parameter is provided e.g. Web Mode
|
||||
if len(state.Template) > 0 && len(state.Body) == 0 {
|
||||
q.Set("template", state.Template)
|
||||
}
|
||||
if len(state.Labels) > 0 {
|
||||
q.Set("labels", strings.Join(state.Labels, ","))
|
||||
}
|
||||
|
|
@ -40,6 +44,7 @@ func WithPrAndIssueQueryParams(client *api.Client, baseRepo ghrepo.Interface, ba
|
|||
if len(state.Milestones) > 0 {
|
||||
q.Set("milestone", state.Milestones[0])
|
||||
}
|
||||
|
||||
u.RawQuery = q.Encode()
|
||||
return u.String(), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ type IssueMetadataState struct {
|
|||
Body string
|
||||
Title string
|
||||
|
||||
Template string
|
||||
|
||||
Metadata []string
|
||||
Reviewers []string
|
||||
Assignees []string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue