mry 0.53.0.0 → 0.54.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/check_rubocop_update +73 -34
- data/lib/mry/added_cops.rb +3 -0
- data/lib/mry/rewriters.rb +4 -0
- data/lib/mry/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b98260ee2465b409a676c987c01451b2770c09a2770e19ceb37a3b5697ada4d0
|
4
|
+
data.tar.gz: 6a4aeb56cd615e3b46f093dc6ab8006a6e18570ba429991a34903ef0bcad6eda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189f6063053bcd4ecc3de1eb9045b09b40af0ab1ce0fb6c6258a441cedaf258e08c5a611b18df2fe1466e3f52f784d55169fead61dd57c207fa00f9e285417c2
|
7
|
+
data.tar.gz: 345f674c312596fe2d5de953893169a8568a2b41aef3bdd548b42b9065605aa6881d84015bf4521dfebfd57c3b3747572732609ccda3bb3feae5049d67c31c1f
|
data/bin/check_rubocop_update
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
# Usage: bin/check_rubocop_update v0.52.1 v0.53.0
|
3
|
+
# Usage: bin/check_rubocop_update v0.52.1 v0.53.0 ~/path/to/rubocop/
|
4
4
|
|
5
5
|
require 'open3'
|
6
6
|
require 'yaml'
|
7
7
|
require 'tmpdir'
|
8
|
+
require 'etc'
|
8
9
|
|
9
10
|
def debug_print(mes)
|
10
11
|
$stdout.puts mes
|
11
12
|
end
|
12
13
|
|
13
|
-
def sh!(*cmd)
|
14
|
+
def sh!(*cmd, **opt)
|
14
15
|
debug_print 'sh!: ' + cmd.join(' ')
|
15
|
-
system(*cmd, exception: true)
|
16
|
+
system(*cmd, opt.merge(exception: true))
|
16
17
|
end
|
17
18
|
|
18
|
-
def capture3!(*cmd)
|
19
|
+
def capture3!(*cmd, **opt)
|
19
20
|
debug_print 'capture3!: ' + cmd.join(' ')
|
20
|
-
Open3.capture3(*cmd).tap do |out, err, status|
|
21
|
+
Open3.capture3(*cmd, **opt).tap do |out, err, status|
|
21
22
|
raise "#{out} #{err}" unless status.success?
|
22
23
|
end
|
23
24
|
end
|
@@ -29,15 +30,12 @@ def each_commit(before, after, &block)
|
|
29
30
|
stdout.each_line.map(&:chomp)
|
30
31
|
end
|
31
32
|
commits.each do |commit|
|
32
|
-
|
33
|
-
sh! 'bundle', 'install' if has_gemfile_change?(commit)
|
34
|
-
sh! 'git', 'checkout', commit
|
35
|
-
block.call
|
33
|
+
block.call commit
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
39
|
-
def has_gemfile_change?(commit)
|
40
|
-
capture3!('git', 'show', '--name-only', '--format=tformat:', commit).yield_self do |stdout, _stderr, _status|
|
37
|
+
def has_gemfile_change?(commit, repo)
|
38
|
+
capture3!('git', 'show', '--name-only', '--format=tformat:', commit, chdir: repo).yield_self do |stdout, _stderr, _status|
|
41
39
|
stdout.each_line.any? do |fname|
|
42
40
|
fname.chomp!
|
43
41
|
fname == 'Gemfile' || fname == 'rubocop.gemspec'
|
@@ -53,40 +51,81 @@ def chtmpdir(&block)
|
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
|
-
def
|
54
|
+
def with_repositories(remote, &block)
|
55
|
+
if File.directory?(remote)
|
56
|
+
Dir.chdir(remote) do
|
57
|
+
sh! 'git', 'fetch', 'origin'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
chtmpdir do
|
62
|
+
repos = Array.new(Etc.nprocessors*2) do |idx|
|
63
|
+
sh! 'git', 'clone', remote, idx.to_s
|
64
|
+
File.join(Dir.pwd, idx.to_s)
|
65
|
+
end
|
66
|
+
block.call(repos)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def cops_each_commit(before, after, remote)
|
71
|
+
with_repositories(remote) do |repos|
|
72
|
+
q = Thread::Queue.new
|
73
|
+
[].tap do |result|
|
74
|
+
Dir.chdir(repos.first) do
|
75
|
+
each_commit(before + '~', after).each.with_index do |commit, idx|
|
76
|
+
q << [commit, idx]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
q.close
|
80
|
+
repos.map do |repo|
|
81
|
+
Thread.new do
|
82
|
+
while v = q.pop
|
83
|
+
commit, idx = *v
|
84
|
+
sh! 'rm', '-f', 'Gemfile.lock', chdir: repo if File.exist?(File.join repo, 'Gemfile.lock')
|
85
|
+
if has_gemfile_change?(commit, repo)
|
86
|
+
begin
|
87
|
+
sh! 'bundle', 'install', '--local', chdir: repo
|
88
|
+
rescue RuntimeError
|
89
|
+
sh! 'bundle', 'install', chdir: repo
|
90
|
+
end
|
91
|
+
end
|
92
|
+
sh! 'git', 'checkout', commit, chdir: repo
|
93
|
+
capture3!('bin/rubocop', '--show-cops', chdir: repo).tap do |stdout, _, _|
|
94
|
+
result << [idx, YAML.load(stdout)]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end.each(&:join)
|
99
|
+
end.sort_by(&:first).map{|_, v| v}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def main(before, after, remote)
|
57
104
|
{}.tap do |result|
|
58
105
|
result[:added] = []
|
59
106
|
result[:renamed] = []
|
60
107
|
result[:deleted] = []
|
61
108
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
removed = old.keys - new.keys
|
73
|
-
if added.size > removed.size && removed.size == 0
|
74
|
-
result[:added].concat added
|
75
|
-
elsif added.size < removed.size && added.size == 0
|
76
|
-
result[:deleted].concat removed
|
77
|
-
elsif added.size != 0 && removed.size != 0
|
78
|
-
result[:renamed] << {before: removed, after: added}
|
79
|
-
end
|
80
|
-
end
|
109
|
+
cops = cops_each_commit(before, after, remote)
|
110
|
+
cops.each_cons(2) do |new, old|
|
111
|
+
added = new.keys - old.keys
|
112
|
+
removed = old.keys - new.keys
|
113
|
+
if added.size > removed.size && removed.size == 0
|
114
|
+
result[:added].concat added
|
115
|
+
elsif added.size < removed.size && added.size == 0
|
116
|
+
result[:deleted].concat removed
|
117
|
+
elsif added.size != 0 && removed.size != 0
|
118
|
+
result[:renamed] << {before: removed, after: added}
|
81
119
|
end
|
82
120
|
end
|
83
121
|
end
|
84
122
|
end
|
85
123
|
|
86
|
-
before = ARGV[0]
|
87
|
-
after
|
124
|
+
before = ARGV[0] || raise
|
125
|
+
after = ARGV[1] || raise
|
126
|
+
remote = ARGV[2] || raise
|
88
127
|
|
89
|
-
out = main(before, after)
|
128
|
+
out = main(before, after, remote)
|
90
129
|
res = YAML.dump(out)
|
91
130
|
puts res
|
92
131
|
fname = '/tmp/mry_check_rubocop_update_log.yaml'
|
data/lib/mry/added_cops.rb
CHANGED
data/lib/mry/rewriters.rb
CHANGED
@@ -3,6 +3,9 @@ module Mry
|
|
3
3
|
class Rewriter_Master < YAMLRewriter::Rewriter
|
4
4
|
end
|
5
5
|
|
6
|
+
class Rewriter_0_54_0 < YAMLRewriter::Rewriter
|
7
|
+
end
|
8
|
+
|
6
9
|
class Rewriter_0_53_0 < YAMLRewriter::Rewriter
|
7
10
|
define_rule ['Naming/UncommunicativeMethodArgName' => 'Naming/UncommunicativeMethodParamName']
|
8
11
|
define_rule ['Lint/ConditionPosition' => 'Layout/ConditionPosition']
|
@@ -159,6 +162,7 @@ module Mry
|
|
159
162
|
end
|
160
163
|
|
161
164
|
Rewriters = {
|
165
|
+
Gem::Version.new('0.54.0') => Rewriter_0_54_0,
|
162
166
|
Gem::Version.new('0.53.0') => Rewriter_0_53_0,
|
163
167
|
Gem::Version.new('0.52.0') => Rewriter_0_52_0,
|
164
168
|
Gem::Version.new('0.51.0') => Rewriter_0_51_0,
|
data/lib/mry/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.54.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|