bake-modernize 0.17.3 → 0.17.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 184e24f86a0a681ca38a59b54e78d61eed0494880d8d7ca1e8003c45a759caba
4
- data.tar.gz: 5af9b347cfd4618c6fdfe06a08f3dc93a33a06ff1e529ea9918d4cb025cecc73
3
+ metadata.gz: f6bf8c1f1f973846d16af55aa30a9b62960b2db001d80e7a19506161a9992203
4
+ data.tar.gz: 047c44563a79018b3163b9dabf1498d23b9f538c3f18a403177b580fb3156157
5
5
  SHA512:
6
- metadata.gz: 728803e53abe00984a92208e0da5dd137c24311c0f3c1ba52d740524dfcab82c8932d6f8f00a72c0eb2e03975d819ff90d8758dcf813bfbf05c1f90b107dcb80
7
- data.tar.gz: 5963dfa6c4519cd50ccf4f6b2e1b85442d1722533c96a0dee3520141873cc47511accef685781411fa065906f4dc8a86f8bd074db8101bc38b90b73064f18601
6
+ metadata.gz: fbea3be9c9830f12f1590704cfddd527bdc7a7876b0cd00b9b6e008c6c17e9a6282dfe2c975ced005292925b57c08e433f374a9de3ba7b49bf9de91d713cef15
7
+ data.tar.gz: 18b73153b2156878413a7dd34b232e12cb4477b2cedf070c4d11bf2ed10a758d7036bfe9c39f436956e24329a2e1a01d48bf3cf4523cf4370ef44806d9c1b8aa
checksums.yaml.gz.sig CHANGED
Binary file
@@ -33,7 +33,7 @@ def update(path: default_gemspec_path, output: $stdout)
33
33
  spec.metadata["funding_uri"] ||= detect_funding_uri(spec)
34
34
  spec.metadata["documentation_uri"] ||= detect_documentation_uri(spec)
35
35
 
36
- spec.authors = sorted_authors(spec)
36
+ spec.authors = sorted_authors(Dir.pwd)
37
37
 
38
38
  spec.metadata.delete_if{|_, value| value.nil?}
39
39
 
@@ -220,23 +220,11 @@ def detect_documentation_uri(spec)
220
220
  end
221
221
  end
222
222
 
223
- def sorted_authors(spec)
224
- input, output = IO.pipe
223
+ def sorted_authors(root)
224
+ authorship = Bake::Modernize::License::Authorship.new
225
+ authorship.extract(root)
225
226
 
226
- pid = Process.spawn("git", "log", "--format=%aN", out: output)
227
- output.close
228
-
229
- authors = Hash.new{|h,k| h[k] = 0}
230
-
231
- input.each_line do |author|
232
- author = author.chomp!
233
- authors[author] += 1
234
- end
235
-
236
- Process.wait(pid)
237
- input.close
238
-
239
- return authors.sort_by{|k,v| [-v, k]}.map(&:first)
227
+ return authorship.sorted_authors
240
228
  end
241
229
 
242
230
  IGNORE_GEMS = %w[
@@ -9,6 +9,39 @@ require 'yaml'
9
9
  module Bake
10
10
  module Modernize
11
11
  module License
12
+ GIT_BLAME_IGNORE_REVS = ".git-blame-ignore-revs"
13
+
14
+ class SkipList
15
+ def self.for(root)
16
+ full_path = File.join(root, GIT_BLAME_IGNORE_REVS)
17
+
18
+ if File.exist?(full_path)
19
+ skip_list = self.new
20
+ skip_list.extract(full_path)
21
+ return skip_list
22
+ end
23
+ end
24
+
25
+ def initialize(revisions = [])
26
+ @revisions = Set.new(revisions)
27
+ end
28
+
29
+ def extract(path)
30
+ File.open(path, 'r') do |file|
31
+ file.each_line do |line|
32
+ # Skip empty lines and comments
33
+ next if line =~ /^\s*(#|$)/
34
+ # Parse line
35
+ @revisions << line.strip
36
+ end
37
+ end
38
+ end
39
+
40
+ def ignore?(commit)
41
+ @revisions.include?(commit.oid)
42
+ end
43
+ end
44
+
12
45
  class Mailmap
13
46
  def self.for(root)
14
47
  full_path = File.join(root, '.mailmap')
@@ -119,6 +152,7 @@ module Bake
119
152
 
120
153
  def extract(root = Dir.pwd)
121
154
  mailmap = Mailmap.for(root)
155
+ skip_list = SkipList.for(root)
122
156
 
123
157
  if contributors = Contributors.for(root)
124
158
  contributors.each do |path, author, time|
@@ -126,11 +160,23 @@ module Bake
126
160
  end
127
161
  end
128
162
 
129
- walk(Rugged::Repository.discover(root), mailmap: mailmap)
163
+ walk(Rugged::Repository.discover(root), mailmap: mailmap, skip_list: skip_list)
130
164
 
131
165
  return self
132
166
  end
133
167
 
168
+ def sorted_authors
169
+ authors = Hash.new{|h,k| h[k] = 0}
170
+
171
+ @paths.each do |path, modifications|
172
+ modifications.each do |modification|
173
+ authors[modification.full_name] += 1
174
+ end
175
+ end
176
+
177
+ return authors.sort_by{|k,v| [-v, k]}.map(&:first)
178
+ end
179
+
134
180
  def copyrights
135
181
  copyrights_for_modifications(@paths.values.flatten)
136
182
  end
@@ -151,8 +197,10 @@ module Bake
151
197
 
152
198
  DEFAULT_SORT = Rugged::SORT_DATE | Rugged::SORT_TOPO | Rugged::SORT_REVERSE
153
199
 
154
- def walk(repository, mailmap: nil, show: "HEAD")
200
+ def walk(repository, mailmap: nil, skip_list: nil, show: "HEAD")
155
201
  Rugged::Walker.walk(repository, show: show, sort: DEFAULT_SORT) do |commit|
202
+ next if skip_list&.ignore?(commit)
203
+
156
204
  diff = commit.diff
157
205
 
158
206
  # We relax the threshold for copy and rename detection because we want to detect files that have been moved and modified more generously.
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.17.3"
8
+ VERSION = "0.17.5"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-modernize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.3
4
+ version: 0.17.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file