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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dbd7868325c3a0d45c8a416a8f5dabede70417f9
4
- data.tar.gz: '0836ec5880102b346009b988f567bfd7004b14d0'
2
+ SHA256:
3
+ metadata.gz: 50d73ff348de6f8b4260b5467c4c6a2b74f558def5f8abca4a763f2c47dd5607
4
+ data.tar.gz: 92a7a6877f185302aa084422dd2e24f83e0cd77945884c43e2d355080e9c66fc
5
5
  SHA512:
6
- metadata.gz: 23a5f9d6e75304f79a51795ca043fbfc84d2529b37ce65a27af447c2974510fbedeed9a01ae8cdfc52ada577369932e773a0f3d9ad0fb56b03635db733e9e385
7
- data.tar.gz: 16256943f523e668735ff45746aa1d40b1f0fc442435b0f546b86fc72d49c553a5a4403365d7d6e89ecf8e54d10999b902ebdaaf2a8b0b3c82005fae68ce6b4c
6
+ metadata.gz: 203911ffe47740f23723ba60860779e5ed3e4a5d8df78f697ce12fe0aace28d6b18e4c6ad025f9518dfccb109014800fd38107fd2f9c718e7ecaa67c64b806f7
7
+ data.tar.gz: 456b807be6b9b5773589b01cc4cd90013e34165f9a81a6750e31cedf487b815a42a81b7f4c722655bbcc88beda5691fa2f5522ba907ffaed336210d8af6ee54c
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.1
4
- - 2.3.4
5
- - 2.2.7
3
+ - 2.5.1
4
+ - 2.4.4
5
+ - 2.3.7
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.
@@ -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, :gem_dictionary
13
- attr_accessor :formatter, :octokit
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 octokit.pull_request_files(repo_full_name, pr_number).find { |resource| resource.filename == "Gemfile.lock" }
25
- pull_request = octokit.pull_request(repo_full_name, pr_number)
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(octokit)
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 = octokit.add_comment(
63
+ res = requested_repository_octokit.add_comment(
66
64
  repo_full_name,
67
65
  pr_number,
68
66
  compare_links
69
67
  )
70
- "https://github.com/#{repo_full_name}/pull/#{pr_number}#issuecomment-#{res.id}"
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
@@ -1,3 +1,3 @@
1
1
  class CompareLinker
2
- VERSION = "1.3.8"
2
+ VERSION = "1.4.0"
3
3
  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.3.8
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: 2017-08-21 00:00:00.000000000 Z
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.11
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