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
Add --json export flag for release list
#8474
base: trunk
Are you sure you want to change the base?
Conversation
--json export flag for release list
|
@samcoe @williammartin : Are these changes necessary because we have different cli/pkg/cmd/release/shared/fetch.go Lines 23 to 124 in 3e1268f
cli/pkg/cmd/release/list/http.go Lines 14 to 32 in 3e1268f
I haven't dug into the history behind the "shared" version especially given it doesn't seem like the only implementation. I worry having these separate code paths makes it difficult to maintain and ensure a consistent experience. |
|
@v1v : Thank you for opening this PR and your patience over the holidays! 🙇 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v1v Thanks for getting started on this work, and your patients. This is looking great so far. I left a couple code comments, please let me know if any of them are unclear. In addition to the addressing the code comments it would be great to add a couple tests to verify the new functionality.
| "time" | ||
|
|
||
| "github.com/cli/cli/v2/api" | ||
| "github.com/cli/cli/v2/internal/ghrepo" | ||
| "github.com/shurcooL/githubv4" | ||
| ) | ||
|
|
||
| var ReleaseFields = []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things here:
- This does not need to be exported
| var ReleaseFields = []string{ | |
| var releaseFields = []string{ |
- In other
releasecommands we already support the--jsonexport and we should try to match the fields that are available there as best we can. We are using the GraphQL endpoint here so not all the fields will be available but the ones that are would be nice to include. One exception I would say are the assets. Including the assets would dramatically increase the data retrieved from therelease listcommand and could have detrimental UX implications.
| @@ -76,3 +88,20 @@ loop: | |||
|
|
|||
| return releases, nil | |||
| } | |||
|
|
|||
| func (r *Release) ExportData(fields []string) map[string]interface{} { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact function has been copy/pasted a couple times in the code base, it would be nice to have a single place for it. I don't think this needs to be addressed in this PR but just a note for the future.
It was similarly solved in #3869 but for the
release listcommand.In addition, I added the same logic for empty results as explained in #6419.
Closes #4572