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:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user