Fix #202: Add dependency_type to bd show --json output (#203)

The JSON output from bd show now includes the dependency_type field
for both dependencies and dependents, enabling programmatic
differentiation between dependency types (blocks, related,
parent-child, discovered-from).

Implementation approach:
- Added IssueWithDependencyMetadata type with embedded Issue and
  DependencyType field
- Extended GetDependenciesWithMetadata and GetDependentsWithMetadata
  to include dependency type from SQL JOIN
- Made GetDependencies and GetDependents wrap the WithMetadata
  methods for backward compatibility
- Added scanIssuesWithDependencyType helper to handle scanning with
  dependency type field
- Updated bd show --json to use WithMetadata methods

Tests added:
- TestGetDependenciesWithMetadata - basic functionality
- TestGetDependentsWithMetadata - dependent retrieval
- TestGetDependenciesWithMetadataEmpty - edge case handling
- TestGetDependenciesWithMetadataMultipleTypes - multiple types

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Happy <yesreply@happy.engineering>
This commit is contained in:
David Laing
2025-11-02 16:40:10 +00:00
committed by GitHub
parent d240439868
commit 50a324db85
5 changed files with 339 additions and 17 deletions

View File

@@ -153,6 +153,13 @@ type DependencyCounts struct {
DependentCount int `json:"dependent_count"` // Number of issues that depend on this issue
}
// IssueWithDependencyMetadata extends Issue with dependency relationship type
// Note: We explicitly include all Issue fields to ensure proper JSON marshaling
type IssueWithDependencyMetadata struct {
Issue
DependencyType DependencyType `json:"dependency_type"`
}
// IssueWithCounts extends Issue with dependency relationship counts
type IssueWithCounts struct {
*Issue