hub_link 0.15.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hub_link.gemspec +0 -1
- data/lib/hub_link/api/pull_request.rb +2 -28
- data/lib/hub_link/api/review.rb +13 -9
- data/lib/hub_link/batch.rb +14 -15
- data/lib/hub_link/configuration.rb +2 -1
- data/lib/hub_link/version.rb +1 -1
- metadata +2 -17
- data/lib/hub_link/core_ext/float.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7393845f06b0f5351385509b348edf549bc06c8e
|
4
|
+
data.tar.gz: ed93dc3da202c40c1b682fb39b4a4c73e7b197f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26a4378f6e71fed9919d5303df7d32c296ab54bbb849f5e1bd0ee5b87168cc249cf8bfc3e807d97f854a8af9c26b5a5ef7aad3d7e6fcb1001f332b60945468db
|
7
|
+
data.tar.gz: 26a50ddbdc5a340b5df5e6271d2dd28fbc982d8813950a35fa9d2deb534c93c7eed6e95b6365d964c8eb9c1314e81303ff9f763bf670fafe8846e77e00a3a811
|
data/hub_link.gemspec
CHANGED
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "dotenv"
|
23
23
|
spec.add_dependency "faraday_middleware"
|
24
24
|
spec.add_dependency "octokit"
|
25
|
-
spec.add_dependency "pastel"
|
26
25
|
|
27
26
|
spec.add_development_dependency "bundler", "~> 1.12"
|
28
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "hub_link/core_ext/float"
|
2
1
|
require "hub_link/api/review"
|
3
2
|
require "hub_link/api/review_request"
|
4
3
|
require "hub_link/slicer"
|
@@ -14,15 +13,11 @@ module HubLink
|
|
14
13
|
updated_at
|
15
14
|
closed_at
|
16
15
|
merged_at
|
17
|
-
approval_time
|
18
|
-
time_to_first_review
|
19
|
-
merge_time
|
20
16
|
body_size
|
21
17
|
additions
|
22
18
|
comments_count
|
23
19
|
review_comments_count
|
24
20
|
submitter
|
25
|
-
straight_approval?
|
26
21
|
labels
|
27
22
|
repo
|
28
23
|
html_url
|
@@ -33,7 +28,7 @@ module HubLink
|
|
33
28
|
Octokit.list_issues(repo, options.merge(page: page, sort: "updated", direction: "asc", state: "all")).map do |item|
|
34
29
|
item.repo = repo
|
35
30
|
new(item)
|
36
|
-
end
|
31
|
+
end
|
37
32
|
end
|
38
33
|
|
39
34
|
def pull_request?
|
@@ -60,28 +55,6 @@ module HubLink
|
|
60
55
|
body.to_s.size
|
61
56
|
end
|
62
57
|
|
63
|
-
def merge_time
|
64
|
-
return unless merged?
|
65
|
-
|
66
|
-
(merged_at - created_at).in_hours
|
67
|
-
end
|
68
|
-
|
69
|
-
def time_to_first_review
|
70
|
-
return if first_review.blank?
|
71
|
-
|
72
|
-
(first_review.submitted_at - created_at).in_hours
|
73
|
-
end
|
74
|
-
|
75
|
-
def approval_time
|
76
|
-
return if first_approval.blank?
|
77
|
-
|
78
|
-
(first_approval.submitted_at - created_at).in_hours
|
79
|
-
end
|
80
|
-
|
81
|
-
def straight_approval?
|
82
|
-
reviews.all?(&:approval?)
|
83
|
-
end
|
84
|
-
|
85
58
|
def merged_at
|
86
59
|
extended_data.merged_at
|
87
60
|
end
|
@@ -118,6 +91,7 @@ module HubLink
|
|
118
91
|
|
119
92
|
def fetch_reviews
|
120
93
|
Octokit.pull_request_reviews(repo, number).map do |data|
|
94
|
+
data.repo = repo
|
121
95
|
data.pull_request_id = id
|
122
96
|
data.number = number
|
123
97
|
data.submitter = submitter
|
data/lib/hub_link/api/review.rb
CHANGED
@@ -6,41 +6,45 @@ module HubLink
|
|
6
6
|
pull_request_id
|
7
7
|
submitted_at
|
8
8
|
reviewer
|
9
|
-
approval?
|
10
9
|
reply?
|
11
10
|
state
|
12
11
|
html_url
|
13
12
|
body
|
13
|
+
review_comments_count
|
14
14
|
)
|
15
15
|
|
16
16
|
def reviewer
|
17
17
|
user&.login
|
18
18
|
end
|
19
19
|
|
20
|
-
def approval?
|
21
|
-
state == "APPROVED"
|
22
|
-
end
|
23
|
-
|
24
20
|
def reply?
|
25
21
|
reviewer == submitter
|
26
22
|
end
|
27
23
|
|
28
|
-
def submitted?
|
29
|
-
!draft?
|
30
|
-
end
|
31
|
-
|
32
24
|
def submitted_at
|
33
25
|
if submitted?
|
34
26
|
super
|
35
27
|
end
|
36
28
|
end
|
37
29
|
|
30
|
+
def review_comments_count
|
31
|
+
review_comments.size
|
32
|
+
end
|
33
|
+
|
38
34
|
def to_h
|
39
35
|
Slicer.new(self, columns: EXPORT_COLUMNS).to_h
|
40
36
|
end
|
41
37
|
|
42
38
|
private
|
43
39
|
|
40
|
+
def review_comments
|
41
|
+
@_review_comments ||= Octokit.pull_request_review_comments(repo, number, id)
|
42
|
+
end
|
43
|
+
|
44
|
+
def submitted?
|
45
|
+
!draft?
|
46
|
+
end
|
47
|
+
|
44
48
|
def draft?
|
45
49
|
state == "PENDING"
|
46
50
|
end
|
data/lib/hub_link/batch.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "pastel"
|
2
1
|
require "hub_link/api/pull_request"
|
3
2
|
|
4
3
|
module HubLink
|
@@ -19,39 +18,43 @@ module HubLink
|
|
19
18
|
|
20
19
|
def pull_requests
|
21
20
|
log "Fetching pull requests" do
|
22
|
-
|
21
|
+
pull_request_results.find_all(&:pull_request?).map(&:to_h)
|
23
22
|
end
|
24
23
|
end
|
25
24
|
|
26
25
|
def reviews
|
27
26
|
log "Fetching reviews" do
|
28
|
-
|
27
|
+
pull_request_results.flat_map(&:reviews).map(&:to_h)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
32
31
|
def review_requests
|
33
32
|
log "Fetching review requests" do
|
34
|
-
|
33
|
+
pull_request_results.flat_map(&:review_requests).map(&:to_h)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
37
|
private
|
39
38
|
|
39
|
+
def pull_request_results
|
40
|
+
results.find_all(&:pull_request?)
|
41
|
+
end
|
42
|
+
|
40
43
|
def results
|
41
44
|
@_results ||= fetch_results
|
42
45
|
end
|
43
46
|
|
47
|
+
def fetch_results
|
48
|
+
log "*Getting issues* #{formatted_options}" do
|
49
|
+
Api::PullRequest.list(options)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
def log(title, &block)
|
45
54
|
logger.info(START) { title }
|
46
55
|
|
47
56
|
block.call.tap do |results|
|
48
|
-
logger.info(FINISH) {
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def fetch_results
|
53
|
-
log pastel.bold("Getting PRs: #{formatted_options}") do
|
54
|
-
Api::PullRequest.list(options)
|
57
|
+
logger.info(FINISH) { "Found #{results.size}" }
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
@@ -62,9 +65,5 @@ module HubLink
|
|
62
65
|
def logger
|
63
66
|
HubLink.logger
|
64
67
|
end
|
65
|
-
|
66
|
-
def pastel
|
67
|
-
@_pastel ||= Pastel.new
|
68
|
-
end
|
69
68
|
end
|
70
69
|
end
|
@@ -6,6 +6,7 @@ require "hub_link/api/logging"
|
|
6
6
|
|
7
7
|
module HubLink
|
8
8
|
class Configuration
|
9
|
+
RETRY_ON = Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Octokit::BadGateway, Octokit::TooManyRequests]
|
9
10
|
attr_accessor :logger
|
10
11
|
|
11
12
|
def initialize
|
@@ -20,8 +21,8 @@ module HubLink
|
|
20
21
|
|
21
22
|
def middleware
|
22
23
|
Faraday::RackBuilder.new do |builder|
|
24
|
+
builder.request :retry, exceptions: RETRY_ON
|
23
25
|
builder.use Api::Logging
|
24
|
-
builder.request :retry
|
25
26
|
builder.use Octokit::Response::RaiseError
|
26
27
|
builder.adapter Faraday.default_adapter
|
27
28
|
end
|
data/lib/hub_link/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hub_link
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Balvig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pastel
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: bundler
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,7 +147,6 @@ files:
|
|
161
147
|
- lib/hub_link/api_logging.rb
|
162
148
|
- lib/hub_link/batch.rb
|
163
149
|
- lib/hub_link/configuration.rb
|
164
|
-
- lib/hub_link/core_ext/float.rb
|
165
150
|
- lib/hub_link/importer.rb
|
166
151
|
- lib/hub_link/insert.rb
|
167
152
|
- lib/hub_link/simple_logger.rb
|