Skip to content

add --discussion-category flag to release cmd#4003

Merged
mislav merged 2 commits intocli:trunkfrom
despreston:3381-release-discussions
Aug 10, 2021
Merged

add --discussion-category flag to release cmd#4003
mislav merged 2 commits intocli:trunkfrom
despreston:3381-release-discussions

Conversation

@despreston
Copy link
Contributor

Flag for signaling that a discussion should be created with the given
category for the release. Discussions are not supported for draft
releases. If a discussion category is given for a draft, an err will be
shown.

Closes #3381

Flag for signaling that a discussion should be created with the given
category for the release. Discussions are not supported for draft
releases. If a discussion category is given for a draft, an err will be
shown.

Closes cli#3381
@despreston
Copy link
Contributor Author

@mislav mislav added the enhancement a request to improve CLI label Aug 4, 2021
@mislav mislav self-assigned this Aug 4, 2021
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.

Thanks for the code and for your patience! I have a couple of minor requests.

Can't wait for this to ship so we can dogfood is from our own release automation!

publish_args+=( -f discussion_category_name="$DISCUSSION_CATEGORY" )

Comment on lines +104 to +105
if cmd.Flags().Changed("discussion-category") && opts.Draft {
return errors.New("Discussions for draft releases not supported")
Copy link
Contributor

Choose a reason for hiding this comment

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

Will the server also error out on this? If yes, I would propose removing the client-side validation. Maybe in the future the platform allows this (e.g. saves the parameter in a draft release and uses it upon publish), and in that case this bit of client-side validation will be unwanted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just tested this. The server creates the release and ignores the discussion category. No message or anything from the server that the discussion category is not allowed for draft releases. Maybe worth relaying that to the backend team or w/e as that might be confusing, especially if you're trying to automate this stuff. I'll leave in this validation and push changes for the rest of your comments. Look forward to hearing your feedback.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine to leave the validation for now. I don't think it's extremely likely that the platform will accept and respect this parameter for draft releases anytime soon.

// maximum number of simultaneous uploads
Concurrency int

DiscussionCategoryName string
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: let's call this DiscussionCategory so it's not overly long!

}
}

if opts.Draft && len(opts.DiscussionCategoryName) > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This validation is redundant if the RunE block already performs validation of cli inputs

Copy link
Contributor Author

@despreston despreston Aug 9, 2021

Choose a reason for hiding this comment

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

I think you'd still need to perform validation after the interactive bit on line 252, because the value of opts.Draft could change.

"prerelease": opts.Prerelease,
"name": opts.Name,
"body": opts.Body,
"discussion_category_name": opts.DiscussionCategoryName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we only add this param if the flag was set? That way we avoid having to change a bunch of old tests

Only add discussion category to request if there is one. This eliminates
the need to update old tests.

Renaming the variable to something shorter.
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.

It looks great. Thank you so much!

@mislav mislav merged commit 4fa984a into cli:trunk Aug 10, 2021
@despreston despreston deleted the 3381-release-discussions branch August 10, 2021 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement a request to improve CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating discussions for a release using the CLI

3 participants