Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions internal/prompter/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ func IndexFor(options []string, answer string) (int, error) {
return -1, NoSuchAnswerErr(answer, options)
}

func IndexesFor(options []string, answers ...string) ([]int, error) {
indexes := make([]int, len(answers))
for i, answer := range answers {
index, err := IndexFor(options, answer)
if err != nil {
return nil, err
}
Comment on lines +147 to +150

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: this will return an error if any answer is not an available option. IndexFor returns -1 for the int index of the answer, which is necessary being a literal with anything 0 or more being a valid index while this has []int.

makes sense

indexes[i] = index
}
return indexes, nil
}

func NoSuchPromptErr(prompt string) error {
return fmt.Errorf("no such prompt '%s'", prompt)
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/cmd/pr/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ func createRun(opts *CreateOptions) error {
if err != nil {
return err
}
// TODO wm: revisit project support
return submitPR(*opts, *ctx, *state, projectsV1Support)
}

Expand Down Expand Up @@ -534,7 +533,7 @@ func createRun(opts *CreateOptions) error {
}
}

openURL, err = generateCompareURL(*ctx, *state, gh.ProjectsV1Supported)
openURL, err = generateCompareURL(*ctx, *state, projectsV1Support)
if err != nil {
return err
}
Expand All @@ -553,8 +552,7 @@ func createRun(opts *CreateOptions) error {
Repo: ctx.PRRefs.BaseRepo(),
State: state,
}
// TODO wm: revisit project support
err = shared.MetadataSurvey(opts.Prompter, opts.IO, ctx.PRRefs.BaseRepo(), fetcher, state, gh.ProjectsV1Supported)
err = shared.MetadataSurvey(opts.Prompter, opts.IO, ctx.PRRefs.BaseRepo(), fetcher, state, projectsV1Support)
if err != nil {
return err
}
Expand Down Expand Up @@ -583,12 +581,10 @@ func createRun(opts *CreateOptions) error {

if action == shared.SubmitDraftAction {
state.Draft = true
// TODO wm: revisit project support
return submitPR(*opts, *ctx, *state, projectsV1Support)
}

if action == shared.SubmitAction {
// TODO wm: revisit project support
return submitPR(*opts, *ctx, *state, projectsV1Support)
}

Expand Down Expand Up @@ -1237,7 +1233,6 @@ func generateCompareURL(ctx CreateContext, state shared.IssueMetadataState, proj
ctx.PRRefs.BaseRepo(),
"compare/%s...%s?expand=1",
url.PathEscape(ctx.PRRefs.BaseRef()), url.PathEscape(ctx.PRRefs.QualifiedHeadRef()))
// TODO wm: revisit project support
url, err := shared.WithPrAndIssueQueryParams(ctx.Client, ctx.PRRefs.BaseRepo(), u, state, projectsV1Support)
if err != nil {
return "", err
Expand Down
Loading