Add project component list command#977
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new jira project component list command to enumerate components for a Jira project, supporting both Jira Cloud (REST v3) and Server/Data Center (REST v2), with multiple output modes.
Changes:
- Introduce Jira client support for fetching project components (v3 and v2) plus proxy routing based on installation type.
- Add CLI command wiring for
jira project component listwith--plainand--rawoutput options. - Add a tabular view renderer and unit tests, plus README documentation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new jira project component list usage and flags. |
| pkg/jira/types.go | Adds ProjectComponent type for API responses. |
| pkg/jira/testdata/components.json | Adds fixture data for component list tests. |
| pkg/jira/component.go | Implements v2/v3 client methods to fetch project components. |
| pkg/jira/component_test.go | Adds unit tests for component fetching (v2/v3). |
| internal/view/component.go | Adds tabular rendering for component lists. |
| internal/view/component_test.go | Adds rendering test coverage for the new component view. |
| internal/cmd/project/project.go | Registers the new project component command tree under project. |
| internal/cmd/project/component/component.go | Adds jira project component parent command and help behavior. |
| internal/cmd/project/component/list/list.go | Implements jira project component list command and output modes. |
| api/client.go | Adds ProxyProjectComponents to select v2 vs v3 endpoint by installation type. |
Comments suppressed due to low confidence (1)
pkg/jira/component_test.go:85
- Same issue here:
assert.Erroris being called with&ErrUnexpectedResponse{}as the error-under-test, so the assertion will always pass and won't validateerr. Switch toassert.ErrorAs/assert.ErrorIsagainsterrto ensure the v2 path returns the expected error for non-200 responses.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| unexpectedStatusCode = true | ||
|
|
||
| _, err = fn(client, "PRJ") | ||
| assert.Error(t, &ErrUnexpectedResponse{}, err) |
There was a problem hiding this comment.
These assertions are not checking the returned error at all. assert.Error expects the error-under-test as its 2nd argument; passing &ErrUnexpectedResponse{} there will always succeed and err is treated only as a message argument. Use assert.ErrorAs(t, err, &jira.ErrUnexpectedResponse{}) (or assert.ErrorIs if applicable) to validate the error type/value for the failing status-code case.
| assert.Error(t, &ErrUnexpectedResponse{}, err) | |
| var unexpectedResponseErr *ErrUnexpectedResponse | |
| assert.ErrorAs(t, err, &unexpectedResponseErr) |
| } | ||
|
|
||
| func outputPlain(components []*jira.ProjectComponent) { | ||
| w := tabwriter.NewWriter(os.Stdout, 0, tabWidth, 1, '\t', 0) | ||
| _, _ = fmt.Fprintln(w, "ID\tNAME\tDESCRIPTION") | ||
|
|
||
| for _, c := range components { | ||
| desc := "" | ||
| if c.Description != nil { | ||
| desc = fmt.Sprint(c.Description) | ||
| } | ||
|
|
||
| _, _ = fmt.Fprintf(w, "%s\t%s\t%s\n", c.ID, c.Name, desc) | ||
| } |
There was a problem hiding this comment.
--plain is described as “tab-delimited/scriptable”, but tabwriter.Writer expands tabs into aligned spaces. That makes the output no longer reliably tab-delimited for scripting/parsing. Consider writing directly with \t separators (optionally behind a bufio.Writer) and skipping tabwriter in plain mode.
|
@copilot apply changes based on the comments in this thread |
Summary
Add support for listing all components belonging to a Jira project.
jira project component listcommand--plainflag for scriptable tab-delimited output--rawflag for JSON outputAPI References
Transparency: LLM Assistance
This PR was developed with GitHub Copilot (Claude Haiku 4.5) as an AI pair programmer. All code was:
go test ./...gofmtTesting
go test ./...All tests pass without regressions.