Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

display single select options in json format #86

Merged
merged 5 commits into from
Apr 19, 2023
Merged

Conversation

mntlty
Copy link
Collaborator

@mntlty mntlty commented Apr 19, 2023

When using --format=json for fields, display the name and id for fields.

Fixes a bug where create-field was sending empty data with single select options.

Set the default color for single select options to gray, as this is a required field by the API.

for _, opt := range config.opts.singleSelectOptions {
opts = append(opts, githubv4.ProjectV2SingleSelectFieldOptionInput{
Name: githubv4.String(opt),
Name: githubv4.String(opt),
Color: githubv4.ProjectV2SingleSelectFieldOptionColor("GRAY"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the api requires a color, testing in the UI this is set as the default

@@ -145,10 +145,11 @@ func createFieldArgs(config createFieldConfig) (*createProjectV2FieldMutation, m
}

if len(config.opts.singleSelectOptions) != 0 {
opts := make([]githubv4.ProjectV2SingleSelectFieldOptionInput, len(config.opts.singleSelectOptions))
opts := make([]githubv4.ProjectV2SingleSelectFieldOptionInput, 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was sending bad data when used with append below, since this will usually be small it's simpler to stick to conventions and not initialize the length even though it's known

@mntlty mntlty merged commit 12f2e75 into main Apr 19, 2023
@mntlty mntlty deleted the single_select_options branch April 19, 2023 21:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant