compare_linker 1.3.8 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -3
- data/README.md +8 -0
- data/lib/compare_linker.rb +29 -9
- data/lib/compare_linker/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 50d73ff348de6f8b4260b5467c4c6a2b74f558def5f8abca4a763f2c47dd5607
|
4
|
+
data.tar.gz: 92a7a6877f185302aa084422dd2e24f83e0cd77945884c43e2d355080e9c66fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 203911ffe47740f23723ba60860779e5ed3e4a5d8df78f697ce12fe0aace28d6b18e4c6ad025f9518dfccb109014800fd38107fd2f9c718e7ecaa67c64b806f7
|
7
|
+
data.tar.gz: 456b807be6b9b5773589b01cc4cd90013e34165f9a81a6750e31cedf487b815a42a81b7f4c722655bbcc88beda5691fa2f5522ba907ffaed336210d8af6ee54c
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -45,6 +45,14 @@ comment = compare_linker.make_compare_links.to_a.join("\n")
|
|
45
45
|
compare_linker.add_comment('masutaka/compare_linker', '17', comment)
|
46
46
|
```
|
47
47
|
|
48
|
+
### GitHub Enterprise
|
49
|
+
In addition to OCTOKIT_ACCESS_TOKEN, set the following environment variables.
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
ENV['ENTERPRISE_OCTOKIT_ACCESS_TOKEN'] = 'xxx'
|
53
|
+
ENV['ENTERPRISE_OCTOKIT_API_ENDPOINT'] = 'https://www.example.com/api/v3'
|
54
|
+
```
|
55
|
+
|
48
56
|
## Development
|
49
57
|
|
50
58
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/compare_linker.rb
CHANGED
@@ -9,22 +9,20 @@ require_relative "compare_linker/lockfile_comparator"
|
|
9
9
|
require_relative "compare_linker/lockfile_fetcher"
|
10
10
|
|
11
11
|
class CompareLinker
|
12
|
-
attr_reader :repo_full_name, :pr_number, :compare_links
|
13
|
-
attr_accessor :formatter
|
12
|
+
attr_reader :repo_full_name, :pr_number, :compare_links
|
13
|
+
attr_accessor :formatter
|
14
14
|
|
15
15
|
def initialize(repo_full_name, pr_number)
|
16
16
|
@repo_full_name = repo_full_name
|
17
17
|
@pr_number = pr_number
|
18
|
-
@octokit ||= Octokit::Client.new(access_token: ENV["OCTOKIT_ACCESS_TOKEN"])
|
19
|
-
@gem_dictionary = GemDictionary.new
|
20
18
|
@formatter = Formatter::Text.new
|
21
19
|
end
|
22
20
|
|
23
21
|
def make_compare_links
|
24
|
-
if
|
25
|
-
pull_request =
|
22
|
+
if requested_repository_octokit.pull_request_files(repo_full_name, pr_number).find { |resource| resource.filename == "Gemfile.lock" }
|
23
|
+
pull_request = requested_repository_octokit.pull_request(repo_full_name, pr_number)
|
26
24
|
|
27
|
-
fetcher = LockfileFetcher.new(
|
25
|
+
fetcher = LockfileFetcher.new(requested_repository_octokit)
|
28
26
|
old_lockfile = fetcher.fetch(repo_full_name, pull_request.base.sha)
|
29
27
|
new_lockfile = fetcher.fetch(repo_full_name, pull_request.head.sha)
|
30
28
|
|
@@ -62,11 +60,33 @@ class CompareLinker
|
|
62
60
|
end
|
63
61
|
|
64
62
|
def add_comment(repo_full_name, pr_number, compare_links)
|
65
|
-
res =
|
63
|
+
res = requested_repository_octokit.add_comment(
|
66
64
|
repo_full_name,
|
67
65
|
pr_number,
|
68
66
|
compare_links
|
69
67
|
)
|
70
|
-
|
68
|
+
res[:html_url]
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
def requested_repository_octokit
|
74
|
+
enterprise_octokit || octokit
|
75
|
+
end
|
76
|
+
|
77
|
+
def enterprise_octokit
|
78
|
+
@enterprise_octokit ||=
|
79
|
+
if ENV["ENTERPRISE_OCTOKIT_ACCESS_TOKEN"] && ENV['ENTERPRISE_OCTOKIT_API_ENDPOINT']
|
80
|
+
Octokit::Client.new(access_token: ENV["ENTERPRISE_OCTOKIT_ACCESS_TOKEN"],
|
81
|
+
api_endpoint: ENV["ENTERPRISE_OCTOKIT_API_ENDPOINT"])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def octokit
|
86
|
+
@octokit ||= Octokit::Client.new(access_token: ENV["OCTOKIT_ACCESS_TOKEN"])
|
87
|
+
end
|
88
|
+
|
89
|
+
def gem_dictionary
|
90
|
+
@gem_dictionary ||= GemDictionary.new
|
71
91
|
end
|
72
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compare_linker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kensuke Nagae
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: octokit
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.6
|
171
|
+
rubygems_version: 2.7.6
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Create GitHub's compare view URLs for pull request
|