From 5fc311374aa270c713593e4f808234d4b374a338 Mon Sep 17 00:00:00 2001 From: Tyler McGoffin Date: Fri, 4 Oct 2024 10:08:48 -0700 Subject: [PATCH] Add handling of empty titles for Issues and PRs Currently, the prompter doesn't enforce the requirement of a title for PR and Issue creation. However, that creates the UX where a user can enter a blank title, spend time filling out a detailed body, then fail to create the issue or pr when the request is sent to the api because the title is blank. This attempts to handle that before sending a request to the api, enforcing that, when prompting, the title of an issue is not blank. --- pkg/cmd/pr/shared/survey.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/pr/shared/survey.go b/pkg/cmd/pr/shared/survey.go index 5b8bde0eb..a059b288c 100644 --- a/pkg/cmd/pr/shared/survey.go +++ b/pkg/cmd/pr/shared/survey.go @@ -111,9 +111,16 @@ func BodySurvey(p Prompt, state *IssueMetadataState, templateContent string) err } func TitleSurvey(p Prompt, state *IssueMetadataState) error { - result, err := p.Input("Title", state.Title) - if err != nil { - return err + var err error + result := "" + for result == "" { + result, err = p.Input("Title (required)", state.Title) + if err != nil { + return err + } + if result == "" { + fmt.Println("X Title cannot be blank.") + } } if result != state.Title {