Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent graphql error #258

Merged
merged 2 commits into from
Jan 28, 2020
Merged

prevent graphql error #258

merged 2 commits into from
Jan 28, 2020

Conversation

vilmibm
Copy link
Contributor

@vilmibm vilmibm commented Jan 27, 2020

this PR catches what would become a graphql error -- a blank PR title upon attempt to create it via the API. A blank title is still legal when previewing in browser (and encouraged, as the expectation is that the user will be filling the title in via the web).

We could take this chance to do something fancy like create a default PR title out of a single commit message but I didn't feel like making a UX decision on that right now; it seemed like handling the graphql error more humanely was good enough for now.

Closes #146

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

This is great; I'm all for helping the user not hit the API errors in the first place.

I'm wondering whether a possible step for improvement could be to ask the user again for a title if it was blank in interactive mode? That way instead of exiting with an error, we offer them a chance to have their PR be successful. This could be a follow-up PR, though.

@@ -174,6 +174,10 @@ func prCreate(cmd *cobra.Command, _ []string) error {
}

if action == SubmitAction {
if title == "" {
return fmt.Errorf("Can't create a PR without a title.")
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. In general, we try to not use capitalization or punctuation in error messages (in fact, go-lint warns about this) to make wrapping of errors easier
  2. Let's use "pull request" instead of PR in user-facing messages
  3. (nitpick) I generally try to avoid contractions in text UIs, perhaps you'd be open to rewording "can't" as "could not" or something similar? Another way to put this could be "pull request title must not be blank"

@vilmibm vilmibm merged commit 25dc2b4 into master Jan 28, 2020
@mislav mislav deleted the blank-title branch February 20, 2020 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow skipping of title field in pr create
2 participants