pronto-github_resolver 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/pronto/github_resolver/version.rb +1 -1
- data/lib/pronto/github_resolver.rb +7 -14
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6724a96a446afe92679d71a695c66caef7ee8bfb0fc67569aa7d11541a3d2682
|
|
4
|
+
data.tar.gz: c9d3681104e1990b423d73e4d3989853f718ae584ce733840665672ee29266b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ef745534dd513e7d1ac9161740f805b7589e8918477e7f01623932717bd0519e7440454920fef6ecca5133244a4bae4dbc9236f801a65928a3b68ab7bb5da717
|
|
7
|
+
data.tar.gz: ad719deed8a69fb7ee362162715b5fee13703d8a9aaa5708379e0828a37d0d08d66049609956e8c4caaff38b5a4dc98cddbae55965e1bea29dcfdad63ac88621
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -22,7 +22,9 @@ Or install it yourself as:
|
|
|
22
22
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
- When any of pronto runners emits message with level `:error` or `:fatal` - generated PR review will have resolution 'REQUEST_CHANGES', and default in other cases.
|
|
26
|
+
- On each run comment threads where message is no longer generated will be marked as resolved.
|
|
27
|
+
- Set ENV['PRONTO_GITHUB_BOT_ID'] to github id of your bot user. This enables posting PR 'APPROVE' review by bot after all messages are resolved.
|
|
26
28
|
|
|
27
29
|
## Development
|
|
28
30
|
|
|
@@ -53,14 +53,6 @@ module Pronto
|
|
|
53
53
|
client.pull_request_reviews(slug, pull_id)
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
def bot_user_id
|
|
57
|
-
bot_user.id
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def bot_user
|
|
61
|
-
@bot_user ||= client.user
|
|
62
|
-
end
|
|
63
|
-
|
|
64
56
|
def get_review_threads
|
|
65
57
|
owner, repo_name = (slug || "").split('/')
|
|
66
58
|
res = client.post :graphql, { query: <<~GQL }.to_json
|
|
@@ -74,7 +66,6 @@ module Pronto
|
|
|
74
66
|
id
|
|
75
67
|
comments(last: 10) {
|
|
76
68
|
nodes {
|
|
77
|
-
author { ... on Node { id } }
|
|
78
69
|
viewerDidAuthor
|
|
79
70
|
path position body
|
|
80
71
|
}
|
|
@@ -98,7 +89,7 @@ module Pronto
|
|
|
98
89
|
node.id,
|
|
99
90
|
node.comments.nodes.map{ |comment|
|
|
100
91
|
{
|
|
101
|
-
|
|
92
|
+
authored: comment.viewerDidAuthor,
|
|
102
93
|
path: comment.path, position: comment.position, body: comment.body
|
|
103
94
|
}
|
|
104
95
|
}
|
|
@@ -137,9 +128,8 @@ module Pronto
|
|
|
137
128
|
if comments.none?
|
|
138
129
|
bot_reviews = client.existing_pull_request_reviews.select { |review| review.user.type == 'Bot' }
|
|
139
130
|
if bot_reviews.any?
|
|
140
|
-
bot_id = client.bot_user_id
|
|
141
131
|
current_bot_review_status = bot_reviews.inject(nil) do |prev_status, review|
|
|
142
|
-
next prev_status unless review
|
|
132
|
+
next prev_status unless review_by_this_bot?(review)
|
|
143
133
|
|
|
144
134
|
case review.state
|
|
145
135
|
when 'CHANGES_REQUESTED' then review.state
|
|
@@ -161,6 +151,10 @@ module Pronto
|
|
|
161
151
|
"#{additions.count} Pronto messages posted to #{pretty_name}"
|
|
162
152
|
end
|
|
163
153
|
|
|
154
|
+
def review_by_this_bot?(review)
|
|
155
|
+
ENV['PRONTO_GITHUB_BOT_ID'] && review.user.id == ENV['PRONTO_GITHUB_BOT_ID'].to_i
|
|
156
|
+
end
|
|
157
|
+
|
|
164
158
|
def submit_comments(client, comments, event: nil)
|
|
165
159
|
client.publish_pull_request_comments(comments, event: event)
|
|
166
160
|
rescue Octokit::UnprocessableEntity, HTTParty::Error => e
|
|
@@ -169,10 +163,9 @@ module Pronto
|
|
|
169
163
|
|
|
170
164
|
def resolve_old_messages(client, repo, actual_comments)
|
|
171
165
|
thread_ids_to_resolve = []
|
|
172
|
-
bot_node_id = client.bot_user.node_id
|
|
173
166
|
client.get_review_threads.each_pair do |thread_id, thread_comments|
|
|
174
167
|
next unless thread_comments.all? do |comment|
|
|
175
|
-
comment[:
|
|
168
|
+
comment[:authored] &&
|
|
176
169
|
(actual_comments[[repo.path.join(comment[:path]), comment[:position]]] || []).none? { |actual_comment|
|
|
177
170
|
comment[:body].include?(actual_comment.body)
|
|
178
171
|
}
|