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

Commit 0268071

Browse files
committed
git pkgs history now works without a package argument
1 parent 6e0b48e commit 0268071

3 files changed

Lines changed: 22 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## [Unreleased]
22

3+
- `git pkgs history` now works without a package argument to show all dependency changes
4+
35
## [0.1.0] - 2026-01-01
46

57
- Initial release

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,14 @@ Gemfile (rubygems):
105105
...
106106
```
107107

108-
### View package history
108+
### View dependency history
109109

110110
```bash
111-
git pkgs history rails
111+
git pkgs history # all dependency changes
112+
git pkgs history rails # changes for a specific package
112113
```
113114

114-
Shows when the package was added, version changes, and removal:
115+
Shows when packages were added, updated, or removed:
115116

116117
```
117118
History for rails:

lib/git/pkgs/commands/history.rb

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ def initialize(args)
1212
def run
1313
package_name = @args.shift
1414

15-
unless package_name
16-
$stderr.puts "Usage: git pkgs history <package>"
17-
exit 1
18-
end
19-
2015
repo = Repository.new
2116

2217
unless Database.exists?(repo.git_dir)
@@ -28,15 +23,20 @@ def run
2823

2924
changes = Models::DependencyChange
3025
.includes(:commit, :manifest)
31-
.for_package(package_name)
3226
.order("commits.committed_at ASC")
3327

28+
changes = changes.for_package(package_name) if package_name
29+
3430
if @options[:ecosystem]
3531
changes = changes.for_platform(@options[:ecosystem])
3632
end
3733

3834
if changes.empty?
39-
puts "No history found for '#{package_name}'"
35+
if package_name
36+
puts "No history found for '#{package_name}'"
37+
else
38+
puts "No dependency changes found"
39+
end
4040
return
4141
end
4242

@@ -48,7 +48,11 @@ def run
4848
end
4949

5050
def output_text(changes, package_name)
51-
puts "History for #{package_name}:"
51+
if package_name
52+
puts "History for #{package_name}:"
53+
else
54+
puts "Dependency history:"
55+
end
5256
puts
5357

5458
changes.each do |change|
@@ -67,7 +71,8 @@ def output_text(changes, package_name)
6771
version_info = change.requirement
6872
end
6973

70-
puts "#{date} #{action} #{version_info}"
74+
name_prefix = package_name ? "" : "#{change.name} "
75+
puts "#{date} #{action} #{name_prefix}#{version_info}"
7176
puts " Commit: #{commit.short_sha} #{commit.message&.lines&.first&.strip}"
7277
puts " Author: #{commit.author_name} <#{commit.author_email}>"
7378
puts " Manifest: #{change.manifest.path}"
@@ -80,6 +85,7 @@ def output_json(changes)
8085

8186
data = changes.map do |change|
8287
{
88+
name: change.name,
8389
date: change.commit.committed_at.iso8601,
8490
change_type: change.change_type,
8591
requirement: change.requirement,
@@ -102,7 +108,7 @@ def parse_options
102108
options = {}
103109

104110
parser = OptionParser.new do |opts|
105-
opts.banner = "Usage: git pkgs history <package> [options]"
111+
opts.banner = "Usage: git pkgs history [package] [options]"
106112

107113
opts.on("-e", "--ecosystem=NAME", "Filter by ecosystem") do |v|
108114
options[:ecosystem] = v

0 commit comments

Comments
 (0)