lock_diff 0.1.7 → 0.2.0
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/lib/lock_diff/diff_info.rb +102 -0
- data/lib/lock_diff/formatter/github_markdown.rb +12 -7
- data/lib/lock_diff/gem/diff_info.rb +7 -24
- data/lib/lock_diff/gem/lockfile_comparator.rb +8 -5
- data/lib/lock_diff/gem/spec.rb +15 -0
- data/lib/lock_diff/gem/version.rb +21 -22
- data/lib/lock_diff/github/tag_finder.rb +38 -0
- data/lib/lock_diff/github.rb +1 -0
- data/lib/lock_diff/version.rb +1 -1
- data/lib/lock_diff.rb +2 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98e0f6cd6557833bfc489091d82b2cd47c378b53
|
4
|
+
data.tar.gz: c4428c319eb30d33df943619e0c9f5eb681f8f01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a8c1c5a632bb6eaac19862c0e5ecfd65db4573044e953beaa0342e0322d20277fb29c2390dfc2024af3cc8419347c412bfc97345a55ef2eb1837d8d4cd1057
|
7
|
+
data.tar.gz: e9648a4468bd361793fb2ff2ac7e8cc4b914e64f00c7e457d0c1c4119bdbba3aedf6b6161f4b6ca3ff5b989ea842b98e901765138ee67534300dc06838664506
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module LockDiff
|
2
|
+
class DiffInfo
|
3
|
+
UPGRADE = 'upgrade'
|
4
|
+
DOWNGRADE = 'downgrade'
|
5
|
+
DELETE = 'delete'
|
6
|
+
NEW = 'new'
|
7
|
+
|
8
|
+
def initialize(old_version:, new_version:, repository:, github_url:)
|
9
|
+
@old_version = old_version
|
10
|
+
@new_version = new_version
|
11
|
+
@repository = repository
|
12
|
+
@github_url = github_url
|
13
|
+
end
|
14
|
+
|
15
|
+
def changed?
|
16
|
+
@old_version.different?(@new_version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def status
|
20
|
+
case
|
21
|
+
when @old_version.version && @new_version.version
|
22
|
+
if @old_version.version < @new_version.version
|
23
|
+
UPGRADE
|
24
|
+
else
|
25
|
+
DOWNGRADE
|
26
|
+
end
|
27
|
+
when @old_version.version
|
28
|
+
DELETE
|
29
|
+
when @new_version.version
|
30
|
+
NEW
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def status_emoji
|
35
|
+
case status
|
36
|
+
when UPGRADE
|
37
|
+
':chart_with_upwards_trend:'
|
38
|
+
when DOWNGRADE
|
39
|
+
':chart_with_downwards_trend:'
|
40
|
+
when DELETE
|
41
|
+
':x:'
|
42
|
+
when NEW
|
43
|
+
':new:'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def change_log_url
|
48
|
+
@change_log_url ||= begin
|
49
|
+
ref =
|
50
|
+
case status
|
51
|
+
when UPGRADE, NEW
|
52
|
+
@new_version.ref
|
53
|
+
when DOWNGRADE, DELETE
|
54
|
+
nil # default branch(master)
|
55
|
+
end
|
56
|
+
|
57
|
+
Github::ChangeLogUrlFinder.new(
|
58
|
+
repository: @repository,
|
59
|
+
github_url: @github_url,
|
60
|
+
ref: ref
|
61
|
+
).call
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def change_log_name
|
66
|
+
File.basename(change_log_url)
|
67
|
+
end
|
68
|
+
|
69
|
+
def commits_url
|
70
|
+
return unless @github_url
|
71
|
+
old_ref = @old_version.ref
|
72
|
+
new_ref = @new_version.ref
|
73
|
+
commits_url =
|
74
|
+
case status
|
75
|
+
when UPGRADE
|
76
|
+
"compare/#{old_ref}...#{new_ref}"
|
77
|
+
when DOWNGRADE
|
78
|
+
"compare/#{new_ref}...#{old_ref}"
|
79
|
+
when DELETE
|
80
|
+
"commits/#{old_ref}"
|
81
|
+
when NEW
|
82
|
+
"commits/#{new_ref}"
|
83
|
+
end
|
84
|
+
|
85
|
+
"#{@github_url}/#{commits_url}"
|
86
|
+
end
|
87
|
+
|
88
|
+
def commits_url_text
|
89
|
+
case status
|
90
|
+
when UPGRADE
|
91
|
+
"#{@old_version}...#{@new_version}"
|
92
|
+
when DOWNGRADE
|
93
|
+
"#{@new_version}...#{@old_version}"
|
94
|
+
when DELETE
|
95
|
+
"#{@old_version}"
|
96
|
+
when NEW
|
97
|
+
"#{@new_version}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
@@ -18,8 +18,8 @@ module LockDiff
|
|
18
18
|
|
19
19
|
def headers
|
20
20
|
[
|
21
|
-
"|
|
22
|
-
"
|
21
|
+
"| name | status | commits | changelog |",
|
22
|
+
"|------|--------|---------|-----------|"
|
23
23
|
]
|
24
24
|
end
|
25
25
|
|
@@ -36,7 +36,8 @@ module LockDiff
|
|
36
36
|
def call
|
37
37
|
text = []
|
38
38
|
text << name
|
39
|
-
text <<
|
39
|
+
text << status
|
40
|
+
text << commits_text
|
40
41
|
text << change_log
|
41
42
|
"| #{text.join(' | ')} |"
|
42
43
|
end
|
@@ -45,15 +46,19 @@ module LockDiff
|
|
45
46
|
|
46
47
|
attr_reader :diff_info
|
47
48
|
|
49
|
+
def status
|
50
|
+
diff_info.status_emoji
|
51
|
+
end
|
52
|
+
|
48
53
|
def name
|
49
54
|
"[#{diff_info.name}](#{diff_info.url})"
|
50
55
|
end
|
51
56
|
|
52
|
-
def
|
53
|
-
if diff_info.
|
54
|
-
"[#{diff_info.
|
57
|
+
def commits_text
|
58
|
+
if diff_info.commits_url
|
59
|
+
"[#{diff_info.commits_url_text}](#{diff_info.commits_url})"
|
55
60
|
else
|
56
|
-
|
61
|
+
diff_info.commits_url_text
|
57
62
|
end
|
58
63
|
end
|
59
64
|
|
@@ -5,6 +5,7 @@ module LockDiff
|
|
5
5
|
|
6
6
|
attr_reader :old_version, :new_version
|
7
7
|
def_delegators :@gem, :name, :url
|
8
|
+
def_delegators :@diff_info, :changed?, :status, :status_emoji, :change_log_url, :change_log_name, :commits_url, :commits_url_text
|
8
9
|
|
9
10
|
def self.by(old_spec:, new_spec:)
|
10
11
|
gem = Gem.new(new_spec.name)
|
@@ -17,30 +18,12 @@ module LockDiff
|
|
17
18
|
|
18
19
|
def initialize(gem:, old_version:, new_version:)
|
19
20
|
@gem = gem
|
20
|
-
@
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
@old_version.version != @new_version.version
|
27
|
-
end
|
28
|
-
|
29
|
-
def change_log_url
|
30
|
-
@change_log_url ||= Github::ChangeLogUrlFinder.new(
|
31
|
-
repository: @gem.repository,
|
32
|
-
github_url: @gem.github_url,
|
33
|
-
ref: @new_version.ref
|
34
|
-
).call
|
35
|
-
end
|
36
|
-
|
37
|
-
def change_log_name
|
38
|
-
File.basename(change_log_url)
|
39
|
-
end
|
40
|
-
|
41
|
-
def diff_url
|
42
|
-
return unless @gem.github_url && @old_version.ref && @new_version.ref
|
43
|
-
"#{@gem.github_url}/compare/#{@old_version.ref}...#{@new_version.ref}"
|
21
|
+
@diff_info = LockDiff::DiffInfo.new(
|
22
|
+
old_version: old_version,
|
23
|
+
new_version: new_version,
|
24
|
+
github_url: gem.github_url,
|
25
|
+
repository: gem.repository
|
26
|
+
)
|
44
27
|
end
|
45
28
|
|
46
29
|
end
|
@@ -15,12 +15,15 @@ module LockDiff
|
|
15
15
|
|
16
16
|
def call
|
17
17
|
old_specs_by_name = Spec.specs_by(@old_lockfile).map { |spec| [spec.name, spec] }.to_h
|
18
|
+
new_specs_by_name = Spec.specs_by(@new_lockfile).map { |spec| [spec.name, spec] }.to_h
|
19
|
+
names = (old_specs_by_name.keys + new_specs_by_name.keys).uniq
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
names.map { |name|
|
22
|
+
DiffInfo.by(
|
23
|
+
old_spec: old_specs_by_name[name] || NullSpec.new(name),
|
24
|
+
new_spec: new_specs_by_name[name] || NullSpec.new(name)
|
25
|
+
)
|
26
|
+
}.select(&:changed?)
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
data/lib/lock_diff/gem/spec.rb
CHANGED
@@ -2,6 +2,7 @@ module LockDiff
|
|
2
2
|
module Gem
|
3
3
|
class Version
|
4
4
|
extend Forwardable
|
5
|
+
include Comparable
|
5
6
|
|
6
7
|
def_delegators :@spec, :revision, :version
|
7
8
|
|
@@ -18,34 +19,32 @@ module LockDiff
|
|
18
19
|
revision || version.to_s
|
19
20
|
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
def git_tag
|
24
|
-
return @git_tag if defined? @git_tag
|
25
|
-
@git_tag = find_tag(limit: 4, per_page: 50)
|
22
|
+
def different?(other)
|
23
|
+
revision != other.revision || version != other.version
|
26
24
|
end
|
27
25
|
|
28
|
-
def
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
fetched_tags = LockDiff.client.tag_names(@gem.repository, page: page, per_page: per_page)
|
33
|
-
tag = fetched_tags.find do |tag_name|
|
34
|
-
tag_name == version_str ||
|
35
|
-
tag_name == "v#{version_str}" ||
|
36
|
-
tag_name == "#{@gem.name}-#{version_str}"
|
37
|
-
end
|
38
|
-
|
39
|
-
if tag
|
40
|
-
return tag
|
26
|
+
def <=>(other)
|
27
|
+
case
|
28
|
+
when version && other.version
|
29
|
+
version.send("<=>", other.version)
|
41
30
|
else
|
42
|
-
|
43
|
-
unless fetched_tags.count < per_page
|
44
|
-
find_tag(page: page + 1, limit: limit, per_page: per_page)
|
45
|
-
end
|
31
|
+
nil
|
46
32
|
end
|
47
33
|
end
|
48
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
def git_tag
|
38
|
+
return unless version
|
39
|
+
return @git_tag if defined? @git_tag
|
40
|
+
@git_tag = Github::TagFinder.new(
|
41
|
+
repository: @gem.repository,
|
42
|
+
gem_name: @gem.name,
|
43
|
+
version_str: version.to_s
|
44
|
+
).call
|
45
|
+
end
|
46
|
+
|
49
47
|
end
|
48
|
+
|
50
49
|
end
|
51
50
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module LockDiff
|
2
|
+
module Github
|
3
|
+
class TagFinder
|
4
|
+
def initialize(repository:, gem_name:, version_str:)
|
5
|
+
@repository = repository
|
6
|
+
@gem_name = gem_name
|
7
|
+
@version_str = version_str
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
find_tag(limit: 4, per_page: 50)
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def find_tag(page: 1, limit:, per_page:)
|
17
|
+
return nil if page > limit
|
18
|
+
|
19
|
+
fetched_tags = LockDiff.client.tag_names(@repository, page: page, per_page: per_page)
|
20
|
+
tag = fetched_tags.find do |tag_name|
|
21
|
+
tag_name == @version_str ||
|
22
|
+
tag_name == "v#{@version_str}" ||
|
23
|
+
tag_name == "#{@gem_name}-#{@version_str}"
|
24
|
+
end
|
25
|
+
|
26
|
+
if tag
|
27
|
+
return tag
|
28
|
+
else
|
29
|
+
LockDiff.logger.debug { "Not found tag of #{@gem_name}, #{@version_str} by page: #{page}, per_page: #{per_page}"}
|
30
|
+
unless fetched_tags.count < per_page
|
31
|
+
find_tag(page: page + 1, limit: limit, per_page: per_page)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/lock_diff/github.rb
CHANGED
data/lib/lock_diff/version.rb
CHANGED
data/lib/lock_diff.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "logger"
|
2
2
|
require "forwardable"
|
3
3
|
|
4
|
+
require "lock_diff/diff_info"
|
4
5
|
require "lock_diff/formatter/github_markdown"
|
5
6
|
require "lock_diff/gem"
|
6
7
|
require "lock_diff/github"
|
@@ -33,7 +34,7 @@ module LockDiff
|
|
33
34
|
if pr
|
34
35
|
run(repository: repository, number: pr.number, post_comment: post_comment)
|
35
36
|
else
|
36
|
-
LockDiff.logger.info("Not found pull request by tachikoma.")
|
37
|
+
LockDiff.logger.info("Not found pull request by tachikoma. (Hint: search pull request by whether branch name includes 'tachikoma'")
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lock_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vividmuimui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- exe/lock_diff
|
132
132
|
- exe/lock_diff_for_tachikoma
|
133
133
|
- lib/lock_diff.rb
|
134
|
+
- lib/lock_diff/diff_info.rb
|
134
135
|
- lib/lock_diff/formatter/github_markdown.rb
|
135
136
|
- lib/lock_diff/gem.rb
|
136
137
|
- lib/lock_diff/gem/diff_info.rb
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- lib/lock_diff/github/github_url_detector.rb
|
149
150
|
- lib/lock_diff/github/pull_request.rb
|
150
151
|
- lib/lock_diff/github/repository_name_detector.rb
|
152
|
+
- lib/lock_diff/github/tag_finder.rb
|
151
153
|
- lib/lock_diff/option_parser.rb
|
152
154
|
- lib/lock_diff/pull_request.rb
|
153
155
|
- lib/lock_diff/version.rb
|