Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit fdab25f

Browse files
committed
Increase test coverage, bug fixes in various commands
1 parent 7ee6066 commit fdab25f

File tree

7 files changed

+1186
-88
lines changed

7 files changed

+1186
-88
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## [0.6.1] - 2026-01-05
44

55
- Fix `stats` command crash on most changed dependencies query
6+
- Fix `search` command SQL alias error when displaying results
7+
- Fix `blame` and `stale` commands eager loading error
8+
- Fix `list` command returning empty output when ecosystem filter matches nothing
69

710
## [0.6.0] - 2026-01-05
811

lib/git/pkgs/commands/blame.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@ def run
2424
error "No analysis found for branch '#{branch_name}'. Run 'git pkgs init' first." unless branch&.last_analyzed_sha
2525

2626
current_commit = Models::Commit.first(sha: branch.last_analyzed_sha)
27-
snapshots = current_commit&.dependency_snapshots&.eager(:manifest) || []
27+
28+
return empty_result("No dependencies found") unless current_commit
29+
30+
snapshots = current_commit.dependency_snapshots_dataset.eager(:manifest)
2831

2932
if @options[:ecosystem]
3033
snapshots = snapshots.where(ecosystem: @options[:ecosystem])
3134
end
3235

36+
snapshots = snapshots.all
37+
3338
if snapshots.empty?
3439
empty_result "No dependencies found"
3540
return

lib/git/pkgs/commands/list.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def run
2424

2525
deps = compute_dependencies_at_commit(target_commit, repo)
2626

27-
if deps.empty?
28-
empty_result "No dependencies found"
29-
return
30-
end
31-
3227
# Apply filters
3328
if @options[:ecosystem]
3429
deps = deps.select { |d| d[:ecosystem] == @options[:ecosystem] }
@@ -38,6 +33,11 @@ def run
3833
deps = deps.select { |d| d[:dependency_type] == @options[:type] }
3934
end
4035

36+
if deps.empty?
37+
empty_result "No dependencies found"
38+
return
39+
end
40+
4141
if @options[:format] == "json"
4242
require "json"
4343
puts JSON.pretty_generate(deps)

lib/git/pkgs/commands/search.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def output_json(matches, pattern)
7272
.where(name: name, ecosystem: platform)
7373
.eager(:commit)
7474
.association_join(:commit)
75-
.order(Sequel[:commits][:committed_at])
75+
.order(Sequel[:commit][:committed_at])
7676
.all
7777

7878
first = changes.first
@@ -98,7 +98,7 @@ def dependency_summary(name, platform)
9898
.where(name: name, ecosystem: platform)
9999
.eager(:commit)
100100
.association_join(:commit)
101-
.order(Sequel[:commits][:committed_at])
101+
.order(Sequel[:commit][:committed_at])
102102
.all
103103

104104
first = changes.first

lib/git/pkgs/commands/stale.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ def run
2323
error "No analysis found for branch '#{branch_name}'. Run 'git pkgs init' first." unless branch&.last_analyzed_sha
2424

2525
current_commit = Models::Commit.first(sha: branch.last_analyzed_sha)
26-
snapshots = current_commit&.dependency_snapshots&.eager(:manifest) || []
26+
27+
return empty_result("No dependencies found") unless current_commit
28+
29+
snapshots = current_commit.dependency_snapshots_dataset.eager(:manifest)
2730

2831
if @options[:ecosystem]
2932
snapshots = snapshots.where(ecosystem: @options[:ecosystem])
3033
end
3134

35+
snapshots = snapshots.all
36+
3237
if snapshots.empty?
3338
empty_result "No dependencies found"
3439
return

lib/git/pkgs/database.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,18 @@ def self.refresh_models
8585
Git::Pkgs::Models::DependencySnapshot
8686
].each do |model|
8787
model.dataset = @db[model.table_name]
88-
# Clear cached association datasets and loaders that may reference old db
88+
# Clear all cached association data that may reference old db
8989
model.association_reflections.each_value do |reflection|
90+
reflection.delete(:_dataset)
91+
reflection.delete(:associated_eager_dataset)
92+
reflection.delete(:placeholder_eager_loader)
93+
reflection.delete(:placeholder_eager_graph_loader)
9094
if reflection[:cache]
91-
reflection[:cache].delete(:_dataset)
92-
reflection[:cache].delete(:associated_eager_dataset)
93-
reflection[:cache].delete(:placeholder_eager_loader)
95+
reflection[:cache].clear
9496
end
9597
end
98+
# Clear model instance caches
99+
model.instance_variable_set(:@columns, nil) if model.instance_variable_defined?(:@columns)
96100
rescue Sequel::Error
97101
# Table may not exist yet
98102
end

0 commit comments

Comments
 (0)