git-pkgs 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +13 -7
- data/lib/git/pkgs/commands/diff.rb +45 -12
- data/lib/git/pkgs/commands/history.rb +16 -10
- data/lib/git/pkgs/repository.rb +6 -0
- data/lib/git/pkgs/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1ab0df1352b215987b6611a997fc62aa1e2a3ea05abe597c134812f9ec17d9d7
|
|
4
|
+
data.tar.gz: 5e929d2ebe9f2538d8d6b29ffc6ac89c7164f2d82afc898954159ae1a4a09ca9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e8eb54a1557bd2fa965fae8dfc2d2cceca578bec650a95821abef16f19ba2d6d6ab7c88a092cddca87de0b111fa9dd526a76439555144a8638f8507201b552e
|
|
7
|
+
data.tar.gz: 288792ce23dc723dcf61d37606cbe26cd89f33052687156d5ae032885c8e963647d972c7b772d4712da03aab024be61eb313992a213bff88d7c02c826937c5a9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.1.1] - 2026-01-01
|
|
4
|
+
|
|
5
|
+
- `git pkgs history` now works without a package argument to show all dependency changes
|
|
6
|
+
- `git pkgs diff` supports git refs (HEAD~10, branch names, tags) not just SHAs
|
|
7
|
+
- `git pkgs diff` lazily inserts commits not found in the database
|
|
8
|
+
- Expanded manifest file pattern matching for all supported ecosystems
|
|
9
|
+
- Switched to ecosystems-bibliothecary
|
|
10
|
+
|
|
3
11
|
## [0.1.0] - 2026-01-01
|
|
4
12
|
|
|
5
13
|
- Initial release
|
data/README.md
CHANGED
|
@@ -20,10 +20,15 @@ gem install git-pkgs
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
cd your-repo
|
|
23
|
-
git pkgs init
|
|
24
|
-
git pkgs
|
|
25
|
-
git pkgs
|
|
26
|
-
git pkgs
|
|
23
|
+
git pkgs init # analyze history (one-time, ~300 commits/sec)
|
|
24
|
+
git pkgs list # show current dependencies
|
|
25
|
+
git pkgs stats # see overview
|
|
26
|
+
git pkgs blame # who added each dependency
|
|
27
|
+
git pkgs history # all dependency changes over time
|
|
28
|
+
git pkgs history rails # track a specific package
|
|
29
|
+
git pkgs why rails # why was this added?
|
|
30
|
+
git pkgs diff --from=HEAD~10 # what changed recently?
|
|
31
|
+
git pkgs diff --from=main --to=feature # compare branches
|
|
27
32
|
```
|
|
28
33
|
|
|
29
34
|
## Commands
|
|
@@ -105,13 +110,14 @@ Gemfile (rubygems):
|
|
|
105
110
|
...
|
|
106
111
|
```
|
|
107
112
|
|
|
108
|
-
### View
|
|
113
|
+
### View dependency history
|
|
109
114
|
|
|
110
115
|
```bash
|
|
111
|
-
git pkgs history
|
|
116
|
+
git pkgs history # all dependency changes
|
|
117
|
+
git pkgs history rails # changes for a specific package
|
|
112
118
|
```
|
|
113
119
|
|
|
114
|
-
Shows when
|
|
120
|
+
Shows when packages were added, updated, or removed:
|
|
115
121
|
|
|
116
122
|
```
|
|
117
123
|
History for rails:
|
|
@@ -19,26 +19,38 @@ module Git
|
|
|
19
19
|
|
|
20
20
|
Database.connect(repo.git_dir)
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
from_ref = @options[:from]
|
|
23
|
+
to_ref = @options[:to] || "HEAD"
|
|
24
|
+
|
|
25
|
+
unless from_ref
|
|
26
|
+
$stderr.puts "Usage: git pkgs diff --from=REF [--to=REF]"
|
|
27
|
+
exit 1
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Resolve git refs (like HEAD~10) to SHAs
|
|
31
|
+
from_sha = repo.rev_parse(from_ref)
|
|
32
|
+
to_sha = repo.rev_parse(to_ref)
|
|
24
33
|
|
|
25
34
|
unless from_sha
|
|
26
|
-
$stderr.puts "
|
|
35
|
+
$stderr.puts "Could not resolve '#{from_ref}'"
|
|
27
36
|
exit 1
|
|
28
37
|
end
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
unless to_sha
|
|
40
|
+
$stderr.puts "Could not resolve '#{to_ref}'"
|
|
41
|
+
exit 1
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
from_commit = find_or_create_commit(repo, from_sha)
|
|
45
|
+
to_commit = find_or_create_commit(repo, to_sha)
|
|
34
46
|
|
|
35
47
|
unless from_commit
|
|
36
|
-
$stderr.puts "Commit '#{from_sha}' not found
|
|
48
|
+
$stderr.puts "Commit '#{from_sha[0..7]}' not found"
|
|
37
49
|
exit 1
|
|
38
50
|
end
|
|
39
51
|
|
|
40
52
|
unless to_commit
|
|
41
|
-
$stderr.puts "Commit '#{to_sha}' not found
|
|
53
|
+
$stderr.puts "Commit '#{to_sha[0..7]}' not found"
|
|
42
54
|
exit 1
|
|
43
55
|
end
|
|
44
56
|
|
|
@@ -98,17 +110,38 @@ module Git
|
|
|
98
110
|
puts "Summary: +#{added.map(&:name).uniq.count} -#{removed.map(&:name).uniq.count} ~#{modified.map(&:name).uniq.count}"
|
|
99
111
|
end
|
|
100
112
|
|
|
113
|
+
def find_or_create_commit(repo, sha)
|
|
114
|
+
commit = Models::Commit.find_by(sha: sha) ||
|
|
115
|
+
Models::Commit.where("sha LIKE ?", "#{sha}%").first
|
|
116
|
+
return commit if commit
|
|
117
|
+
|
|
118
|
+
# Lazily insert commit if it exists in git but not in database
|
|
119
|
+
rugged_commit = repo.lookup(sha)
|
|
120
|
+
return nil unless rugged_commit
|
|
121
|
+
|
|
122
|
+
Models::Commit.create!(
|
|
123
|
+
sha: rugged_commit.oid,
|
|
124
|
+
message: rugged_commit.message,
|
|
125
|
+
author_name: rugged_commit.author[:name],
|
|
126
|
+
author_email: rugged_commit.author[:email],
|
|
127
|
+
committed_at: rugged_commit.time,
|
|
128
|
+
has_dependency_changes: false
|
|
129
|
+
)
|
|
130
|
+
rescue Rugged::OdbError
|
|
131
|
+
nil
|
|
132
|
+
end
|
|
133
|
+
|
|
101
134
|
def parse_options
|
|
102
135
|
options = {}
|
|
103
136
|
|
|
104
137
|
parser = OptionParser.new do |opts|
|
|
105
|
-
opts.banner = "Usage: git pkgs diff --from=
|
|
138
|
+
opts.banner = "Usage: git pkgs diff --from=REF [--to=REF] [options]"
|
|
106
139
|
|
|
107
|
-
opts.on("-f", "--from=
|
|
140
|
+
opts.on("-f", "--from=REF", "Start commit (required)") do |v|
|
|
108
141
|
options[:from] = v
|
|
109
142
|
end
|
|
110
143
|
|
|
111
|
-
opts.on("-t", "--to=
|
|
144
|
+
opts.on("-t", "--to=REF", "End commit (default: HEAD)") do |v|
|
|
112
145
|
options[:to] = v
|
|
113
146
|
end
|
|
114
147
|
|
|
@@ -12,11 +12,6 @@ module Git
|
|
|
12
12
|
def run
|
|
13
13
|
package_name = @args.shift
|
|
14
14
|
|
|
15
|
-
unless package_name
|
|
16
|
-
$stderr.puts "Usage: git pkgs history <package>"
|
|
17
|
-
exit 1
|
|
18
|
-
end
|
|
19
|
-
|
|
20
15
|
repo = Repository.new
|
|
21
16
|
|
|
22
17
|
unless Database.exists?(repo.git_dir)
|
|
@@ -28,15 +23,20 @@ module Git
|
|
|
28
23
|
|
|
29
24
|
changes = Models::DependencyChange
|
|
30
25
|
.includes(:commit, :manifest)
|
|
31
|
-
.for_package(package_name)
|
|
32
26
|
.order("commits.committed_at ASC")
|
|
33
27
|
|
|
28
|
+
changes = changes.for_package(package_name) if package_name
|
|
29
|
+
|
|
34
30
|
if @options[:ecosystem]
|
|
35
31
|
changes = changes.for_platform(@options[:ecosystem])
|
|
36
32
|
end
|
|
37
33
|
|
|
38
34
|
if changes.empty?
|
|
39
|
-
|
|
35
|
+
if package_name
|
|
36
|
+
puts "No history found for '#{package_name}'"
|
|
37
|
+
else
|
|
38
|
+
puts "No dependency changes found"
|
|
39
|
+
end
|
|
40
40
|
return
|
|
41
41
|
end
|
|
42
42
|
|
|
@@ -48,7 +48,11 @@ module Git
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def output_text(changes, package_name)
|
|
51
|
-
|
|
51
|
+
if package_name
|
|
52
|
+
puts "History for #{package_name}:"
|
|
53
|
+
else
|
|
54
|
+
puts "Dependency history:"
|
|
55
|
+
end
|
|
52
56
|
puts
|
|
53
57
|
|
|
54
58
|
changes.each do |change|
|
|
@@ -67,7 +71,8 @@ module Git
|
|
|
67
71
|
version_info = change.requirement
|
|
68
72
|
end
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
name_prefix = package_name ? "" : "#{change.name} "
|
|
75
|
+
puts "#{date} #{action} #{name_prefix}#{version_info}"
|
|
71
76
|
puts " Commit: #{commit.short_sha} #{commit.message&.lines&.first&.strip}"
|
|
72
77
|
puts " Author: #{commit.author_name} <#{commit.author_email}>"
|
|
73
78
|
puts " Manifest: #{change.manifest.path}"
|
|
@@ -80,6 +85,7 @@ module Git
|
|
|
80
85
|
|
|
81
86
|
data = changes.map do |change|
|
|
82
87
|
{
|
|
88
|
+
name: change.name,
|
|
83
89
|
date: change.commit.committed_at.iso8601,
|
|
84
90
|
change_type: change.change_type,
|
|
85
91
|
requirement: change.requirement,
|
|
@@ -102,7 +108,7 @@ module Git
|
|
|
102
108
|
options = {}
|
|
103
109
|
|
|
104
110
|
parser = OptionParser.new do |opts|
|
|
105
|
-
opts.banner = "Usage: git pkgs history
|
|
111
|
+
opts.banner = "Usage: git pkgs history [package] [options]"
|
|
106
112
|
|
|
107
113
|
opts.on("-e", "--ecosystem=NAME", "Filter by ecosystem") do |v|
|
|
108
114
|
options[:ecosystem] = v
|
data/lib/git/pkgs/repository.rb
CHANGED
data/lib/git/pkgs/version.rb
CHANGED