pronto-github_resolver 0.0.2 → 0.0.3

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
2
  SHA256:
3
- metadata.gz: 152e4319e389105c14b8c208f8b668c17a25eafbab0f1270b00c071994f9320c
4
- data.tar.gz: b7a1b40e35543a93e7924e82a7b3596e35ac9e416df34855939112e5222db953
3
+ metadata.gz: 6724a96a446afe92679d71a695c66caef7ee8bfb0fc67569aa7d11541a3d2682
4
+ data.tar.gz: c9d3681104e1990b423d73e4d3989853f718ae584ce733840665672ee29266b6
5
5
  SHA512:
6
- metadata.gz: 46e7f768e794754c2e2d1159779332f980408d77f5fe4c88f825ed63c27c85dad49318c66da9236ca05d133532de5c6d20a3d39df9c8bd68eef7141bf1763368
7
- data.tar.gz: '0758a279f57ba8c0a153528f0b2b06ab3baee909e396e92c86845b86672f18d312ec41f9efbc574f45cf5aa1ec093f988ae728fd987a72e3d571b31f074d5201'
6
+ metadata.gz: ef745534dd513e7d1ac9161740f805b7589e8918477e7f01623932717bd0519e7440454920fef6ecca5133244a4bae4dbc9236f801a65928a3b68ab7bb5da717
7
+ data.tar.gz: ad719deed8a69fb7ee362162715b5fee13703d8a9aaa5708379e0828a37d0d08d66049609956e8c4caaff38b5a4dc98cddbae55965e1bea29dcfdad63ac88621
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pronto-github_resolver (0.0.2)
4
+ pronto-github_resolver (0.0.3)
5
5
  pronto (~> 0.11)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -22,7 +22,9 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pronto
4
4
  module GithubResolver
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
@@ -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
- author_id: comment.author.id,
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.user.id == bot_id
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[:author_id] == bot_node_id &&
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
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-github_resolver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Fedoseyev