ghrt 0.2.0 → 0.3.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/.gitignore +1 -0
- data/exe/ghrt +3 -0
- data/lib/ghrt/github.rb +14 -2
- data/lib/ghrt/reviewer_comments.rb +8 -1
- data/lib/ghrt/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: 6558be581003cb72c9e3210a5aec53a1684d72e3e2a2b33782c85666ee23e088
|
4
|
+
data.tar.gz: 716457659603c23fcfcad5ad534f1ef81cca79fa086dff79005e17c8b09f8a3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22997d7f8ce3e15f8775bc963e263c99b63cbe64dbf5f49cef97971afc83e40ee11325a81dd4cfcf5c51945d524faa63fddd3f6bfda53d1ddf43a28217ce5c43
|
7
|
+
data.tar.gz: 76003d00b83d201d1e98b100b086d05ce446fc4b9d52bb98aa00fb1a765da6e8e672ecdf17b99344c1e2fbaac7bc9bd16a9ef9b7173d03a77bdd36fcf1c9eb8f
|
data/.gitignore
CHANGED
data/exe/ghrt
CHANGED
@@ -30,6 +30,9 @@ OptionParser.new do |opts|
|
|
30
30
|
opts.on('-s', '--since <yyyy-mm-dd>', 'Only return comments since ISO date') do |date|
|
31
31
|
options[:since] = date
|
32
32
|
end
|
33
|
+
|
34
|
+
opts.separator ''
|
35
|
+
opts.separator "Version #{Ghrt::VERSION}"
|
33
36
|
end.parse!
|
34
37
|
|
35
38
|
raise '--repo and --pull-request parameters must be provided' unless options[:repo] && options[:pr]
|
data/lib/ghrt/github.rb
CHANGED
@@ -11,11 +11,23 @@ module Ghrt
|
|
11
11
|
@repo = repo
|
12
12
|
@username = ENV['GITHUB_USERNAME']
|
13
13
|
@token = ENV['GITHUB_TOKEN']
|
14
|
+
raise 'GITHUB_USERNAME and GITHUB_TOKEN environment variables must be set' unless @username && @token
|
15
|
+
|
14
16
|
@verbose = verbose
|
15
17
|
end
|
16
18
|
|
17
19
|
def review_comments(pull_request, since)
|
18
|
-
response =
|
20
|
+
response = []
|
21
|
+
page = 1
|
22
|
+
|
23
|
+
loop do
|
24
|
+
paged_response = query_github("/pulls/#{pull_request}/comments?since=#{since}&per_page=100&page=#{page}")
|
25
|
+
break if paged_response.empty?
|
26
|
+
|
27
|
+
response.concat(paged_response)
|
28
|
+
page += 1
|
29
|
+
end
|
30
|
+
|
19
31
|
response.select { |comment| comment['user']['login'] == @username }
|
20
32
|
end
|
21
33
|
|
@@ -35,7 +47,7 @@ module Ghrt
|
|
35
47
|
end
|
36
48
|
|
37
49
|
def parse_response(response)
|
38
|
-
puts response if @verbose
|
50
|
+
puts response.code if @verbose
|
39
51
|
raise "Unexpected API response status #{response.code}" unless response.code == '200'
|
40
52
|
|
41
53
|
JSON.parse(response.read_body)
|
@@ -27,7 +27,7 @@ module Ghrt
|
|
27
27
|
<div class="col-xl-12 mb-2">
|
28
28
|
<a target="_blank" href='#{comment['html_url']}'><h3>##{index + 1} - #{comment['path']}:#{comment['original_position']}</h3></a>
|
29
29
|
<div class="pl-3">
|
30
|
-
<pre class="prettyprint"><code
|
30
|
+
<pre class="prettyprint"><code>#{normalise_diff_hunk(comment['diff_hunk'])}</code></pre>
|
31
31
|
<div class="text-muted" style="font-size: 1.1em">#{Kramdown::Document.new(comment['body']).to_html}</div>
|
32
32
|
</div>
|
33
33
|
</div>
|
@@ -42,5 +42,12 @@ module Ghrt
|
|
42
42
|
HTML
|
43
43
|
end
|
44
44
|
# rubocop:enable Metrics/MethodLength
|
45
|
+
|
46
|
+
# Make hunks 6 lines long and remove headers
|
47
|
+
def self.normalise_diff_hunk(hunk)
|
48
|
+
return hunk.lines.to_a[1..-1].join if hunk.lines.count <= 6
|
49
|
+
|
50
|
+
hunk.lines.to_a[(hunk.lines.count - 6)..-1].join
|
51
|
+
end
|
45
52
|
end
|
46
53
|
end
|
data/lib/ghrt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghrt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Leaver
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01
|
11
|
+
date: 2019-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|