Skip to content

Add project component list command#977

Open
lehmanju wants to merge 2 commits intoankitpokhrel:mainfrom
lehmanju:get-components
Open

Add project component list command#977
lehmanju wants to merge 2 commits intoankitpokhrel:mainfrom
lehmanju:get-components

Conversation

@lehmanju
Copy link
Copy Markdown

@lehmanju lehmanju commented Apr 8, 2026

Summary

Add support for listing all components belonging to a Jira project.

  • Implement jira project component list command
  • Support both Jira Cloud (REST API v3) and Server/Data Center (REST API v2) endpoints
  • Add --plain flag for scriptable tab-delimited output
  • Add --raw flag for JSON output
  • Add comprehensive unit tests and view rendering

API References

Transparency: LLM Assistance

This PR was developed with GitHub Copilot (Claude Haiku 4.5) as an AI pair programmer. All code was:

  • Reviewed for correctness and security
  • Tested with go test ./...
  • Formatted with gofmt
  • Validated against project conventions and API specifications

Testing

go test ./...

All tests pass without regressions.

Copilot AI review requested due to automatic review settings April 8, 2026 13:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 list with --plain and --raw output 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.Error is being called with &ErrUnexpectedResponse{} as the error-under-test, so the assertion will always pass and won't validate err. Switch to assert.ErrorAs/assert.ErrorIs against err to 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)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
assert.Error(t, &ErrUnexpectedResponse{}, err)
var unexpectedResponseErr *ErrUnexpectedResponse
assert.ErrorAs(t, err, &unexpectedResponseErr)

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +100
}

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)
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

--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 uses AI. Check for mistakes.
@lehmanju
Copy link
Copy Markdown
Author

lehmanju commented Apr 8, 2026

@copilot apply changes based on the comments in this thread

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.

2 participants