refactor: Extract IssueDetails to shared type (bd-6dnt)

Consolidated 5 duplicate IssueDetails struct definitions into a single
types.IssueDetails in internal/types/types.go:

- Removed 4 inline definitions from cmd/bd/show.go
- Removed 1 inline definition from internal/rpc/server_issues_epics.go

The shared type embeds types.Issue by value and includes:
Labels, Dependencies, Dependents, Comments, and Parent fields.

This improves maintainability and reduces risk of inconsistency.
This commit is contained in:
Steve Yegge
2025-12-29 14:04:20 -08:00
parent 2c57d41275
commit 96c7cceefc
3 changed files with 17 additions and 45 deletions

View File

@@ -1305,16 +1305,8 @@ func (s *Server) handleShow(req *Request) Response {
comments, _ := store.GetIssueComments(ctx, issue.ID)
// Create detailed response with related data
type IssueDetails struct {
*types.Issue
Labels []string `json:"labels,omitempty"`
Dependencies []*types.IssueWithDependencyMetadata `json:"dependencies,omitempty"`
Dependents []*types.IssueWithDependencyMetadata `json:"dependents,omitempty"`
Comments []*types.Comment `json:"comments,omitempty"`
}
details := &IssueDetails{
Issue: issue,
details := &types.IssueDetails{
Issue: *issue,
Labels: labels,
Dependencies: deps,
Dependents: dependents,

View File

@@ -483,6 +483,17 @@ type IssueWithCounts struct {
DependentCount int `json:"dependent_count"`
}
// IssueDetails extends Issue with labels, dependencies, dependents, and comments.
// Used for JSON serialization in bd show and RPC responses.
type IssueDetails struct {
Issue
Labels []string `json:"labels,omitempty"`
Dependencies []*IssueWithDependencyMetadata `json:"dependencies,omitempty"`
Dependents []*IssueWithDependencyMetadata `json:"dependents,omitempty"`
Comments []*Comment `json:"comments,omitempty"`
Parent *string `json:"parent,omitempty"`
}
// DependencyType categorizes the relationship
type DependencyType string