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

Commit 4e73e41

Browse files
committed
Enhance dependency listing by including locked versions and manifest kind
1 parent de9f600 commit 4e73e41

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

lib/git/pkgs/analyzer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ def dependencies_at_commit(rugged_commit)
313313
manifest_path: path,
314314
name: dep[:name],
315315
ecosystem: result[:platform],
316+
kind: result[:kind],
316317
requirement: dep[:requirement],
317318
dependency_type: dep[:type]
318319
}

lib/git/pkgs/commands/list.rb

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,21 @@ def run
3939
return
4040
end
4141

42+
locked_versions = build_locked_versions(deps)
43+
4244
if @options[:format] == "json"
4345
require "json"
44-
puts JSON.pretty_generate(deps)
46+
deps_with_locked = deps.map do |dep|
47+
if dep[:kind] == "manifest"
48+
locked = locked_versions[[dep[:ecosystem], dep[:name]]]
49+
locked ? dep.merge(locked_version: locked) : dep
50+
else
51+
dep
52+
end
53+
end
54+
puts JSON.pretty_generate(deps_with_locked)
4555
else
46-
paginate { output_text(deps) }
56+
paginate { output_text(deps, locked_versions) }
4757
end
4858
end
4959

@@ -68,14 +78,25 @@ def run_with_database(repo)
6878
compute_dependencies_at_commit(target_commit, repo)
6979
end
7080

71-
def output_text(deps)
81+
def build_locked_versions(deps)
82+
locked_versions = {}
83+
deps.each do |d|
84+
next unless d[:kind] == "lockfile"
85+
locked_versions[[d[:ecosystem], d[:name]]] = d[:requirement]
86+
end
87+
locked_versions
88+
end
89+
90+
def output_text(deps, locked_versions)
7291
grouped = deps.group_by { |d| [d[:manifest_path], d[:ecosystem]] }
7392

7493
grouped.each do |(path, platform), manifest_deps|
7594
puts "#{path} (#{platform}):"
7695
manifest_deps.sort_by { |d| d[:name] }.each do |dep|
77-
type_suffix = dep[:dependency_type] ? " [#{dep[:dependency_type]}]" : ""
78-
puts " #{dep[:name]} #{dep[:requirement]}#{type_suffix}"
96+
type_suffix = dep[:dependency_type] && dep[:dependency_type] != "runtime" ? " [#{dep[:dependency_type]}]" : ""
97+
locked = locked_versions[[dep[:ecosystem], dep[:name]]] if dep[:kind] == "manifest"
98+
locked_suffix = locked ? " [#{locked}]" : ""
99+
puts " #{dep[:name]} #{dep[:requirement]}#{locked_suffix}#{type_suffix}"
79100
end
80101
puts
81102
end
@@ -103,6 +124,7 @@ def compute_dependencies_at_commit(target_commit, repo)
103124
manifest_path: s.manifest.path,
104125
name: s.name,
105126
ecosystem: s.ecosystem,
127+
kind: s.manifest.kind,
106128
requirement: s.requirement,
107129
dependency_type: s.dependency_type
108130
}
@@ -111,7 +133,7 @@ def compute_dependencies_at_commit(target_commit, repo)
111133

112134
# Replay changes from snapshot to target
113135
if snapshot_commit && snapshot_commit.id != target_commit.id
114-
commit_ids = branch.commits_dataset.select_map(:id)
136+
commit_ids = branch.commits_dataset.select_map(Sequel[:commits][:id])
115137
changes = Models::DependencyChange
116138
.join(:commits, id: :commit_id)
117139
.where(Sequel[:commits][:id] => commit_ids)
@@ -129,6 +151,7 @@ def compute_dependencies_at_commit(target_commit, repo)
129151
manifest_path: change.manifest.path,
130152
name: change.name,
131153
ecosystem: change.ecosystem,
154+
kind: change.manifest.kind,
132155
requirement: change.requirement,
133156
dependency_type: change.dependency_type
134157
}

0 commit comments

Comments
 (0)