lita-github-pinger 0.8.0 → 0.9.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 +5 -5
- data/README.md +6 -3
- data/lib/lita/handlers/github_pinger.rb +91 -23
- data/lita-github-pinger.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 322d659976706040591b8a6adace708b6e62f993e4a9a2eeb9de11962313cd43
|
4
|
+
data.tar.gz: 267a815221c9c91ab85d08b132489557a0e637da78e6bccfb671fbb0dd37c15c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd1d060e1173b44d67146db57da5561651be71c931a3709cb246a27c50691a41523617123326a5f26da1022ceab31aa2681be850d99df375d414ebc8394a5588
|
7
|
+
data.tar.gz: '0769961ff55185d99db6b3b84f336a2d1face79a2aafcbf00de381e84b6c6beee99cdc356da5012ad12b2aaaa1943dd9a2bec5e9ae691e6a7d315f33004833c9'
|
data/README.md
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
This is a Lita handler for pinging you about github events that you should know about.
|
4
4
|
|
5
|
-
In particular, it
|
5
|
+
In particular, it can ping you under four circumstances (right now):
|
6
6
|
|
7
7
|
1. Somebody has commented on your pull request
|
8
8
|
2. Somebody has @mentioned you through a comment on a pull request
|
9
9
|
3. Somebody has assigned you to a pull request
|
10
|
-
4.
|
10
|
+
4. Somebody has requested a pull request review from you
|
11
|
+
5. The status of your pull request was set to "failing"
|
11
12
|
|
12
13
|
## Installation
|
13
14
|
|
@@ -38,9 +39,11 @@ config.handlers.github_pinger.engineers = {
|
|
38
39
|
},
|
39
40
|
github_preferences: {
|
40
41
|
frequency: "all_discussion",
|
42
|
+
notify_about_assignment: true,
|
43
|
+
notify_about_review_requests: true,
|
41
44
|
location: "dm"
|
42
45
|
},
|
43
|
-
|
46
|
+
status_preferences: {
|
44
47
|
frequency: "only_failures"
|
45
48
|
}
|
46
49
|
},
|
@@ -16,7 +16,9 @@ module Lita
|
|
16
16
|
# },
|
17
17
|
# :github_preferences => {
|
18
18
|
# :frequency => "only_mentions",
|
19
|
-
# :ping_location => "dm"
|
19
|
+
# :ping_location => "dm",
|
20
|
+
# :notify_about_review_requests: true,
|
21
|
+
# :notify_about_assignment: true,
|
20
22
|
# },
|
21
23
|
# :travis_preferences => {
|
22
24
|
# :frequency => "only_failures"
|
@@ -34,12 +36,12 @@ module Lita
|
|
34
36
|
# - "off"
|
35
37
|
# default: "all_discussion"
|
36
38
|
#
|
37
|
-
# :
|
39
|
+
# :status_preferences[:frequency] can be
|
38
40
|
# - "only_passes"
|
39
41
|
# - "only_failures"
|
40
42
|
# - "everything"
|
41
43
|
# - "off"
|
42
|
-
# default: "
|
44
|
+
# default: "everything"
|
43
45
|
config :engineers, type: Hash, required: true
|
44
46
|
config :enable_round_robin, types: [TrueClass, FalseClass]
|
45
47
|
|
@@ -60,6 +62,10 @@ module Lita
|
|
60
62
|
act_on_assign(body, response)
|
61
63
|
end
|
62
64
|
|
65
|
+
if body["action"] && body["action"] == "review_requested"
|
66
|
+
act_on_review_requested(body, response)
|
67
|
+
end
|
68
|
+
|
63
69
|
if body["action"] && body["action"] == "labeled"
|
64
70
|
act_on_pr_labeled(body, response)
|
65
71
|
end
|
@@ -77,12 +83,23 @@ module Lita
|
|
77
83
|
commit_url = body["commit"]["html_url"]
|
78
84
|
committer = find_engineer(github: body["commit"]["committer"]["login"])
|
79
85
|
|
80
|
-
puts "Detected a
|
81
|
-
message = ":x: Your commit failed
|
86
|
+
puts "Detected a status failure for commit #{body["sha"]}"
|
87
|
+
message = ":x: Your commit failed CI."
|
82
88
|
message += "\n#{commit_url}"
|
83
89
|
|
84
|
-
|
85
|
-
|
90
|
+
if committer
|
91
|
+
frequency = if committer[:travis_preferences]
|
92
|
+
committer[:travis_preferences][:frequency]
|
93
|
+
else
|
94
|
+
committer[:status_preferences][:frequency]
|
95
|
+
end
|
96
|
+
|
97
|
+
return if ["off", "only_passes"].include?(frequency)
|
98
|
+
|
99
|
+
send_dm(committer[:usernames][:slack], message)
|
100
|
+
else
|
101
|
+
puts "Could not find configuration for GitHub username " + body["commit"]["committer"]["login"]}
|
102
|
+
end
|
86
103
|
|
87
104
|
response
|
88
105
|
end
|
@@ -91,12 +108,23 @@ module Lita
|
|
91
108
|
commit_url = body["commit"]["html_url"]
|
92
109
|
committer = find_engineer(github: body["commit"]["committer"]["login"])
|
93
110
|
|
94
|
-
puts "Detected a
|
95
|
-
message = ":white_check_mark: Your commit has passed
|
111
|
+
puts "Detected a status success for commit #{body["sha"]}"
|
112
|
+
message = ":white_check_mark: Your commit has passed CI."
|
96
113
|
message += "\n#{commit_url}"
|
97
114
|
|
98
|
-
|
99
|
-
|
115
|
+
if committer
|
116
|
+
frequency = if committer[:travis_preferences]
|
117
|
+
committer[:travis_preferences][:frequency]
|
118
|
+
else
|
119
|
+
committer[:status_preferences][:frequency]
|
120
|
+
end
|
121
|
+
|
122
|
+
return if ["off", "only_failures"].include?(frequency)
|
123
|
+
|
124
|
+
send_dm(committer[:usernames][:slack], message)
|
125
|
+
else
|
126
|
+
puts "Could not find configuration for GitHub username " + body["commit"]["committer"]["login"]}
|
127
|
+
end
|
100
128
|
|
101
129
|
response
|
102
130
|
end
|
@@ -105,18 +133,26 @@ module Lita
|
|
105
133
|
type = detect_type(body)
|
106
134
|
|
107
135
|
if type.nil?
|
108
|
-
puts
|
136
|
+
puts "Neither pull request or issue detected, exiting..."
|
109
137
|
return
|
110
138
|
end
|
111
139
|
|
112
140
|
puts "Detected that someone got assigned to a #{type.tr('_', ' ')}."
|
113
141
|
|
114
|
-
assignee_login = body[type][
|
142
|
+
assignee_login = body[type]["assignee"]["login"]
|
115
143
|
assignee = find_engineer(github: assignee_login)
|
116
144
|
|
145
|
+
puts "Looking up preferences..."
|
146
|
+
should_notify = assignee[:github_preferences][:notify_about_assignment]
|
147
|
+
|
148
|
+
if !should_notify
|
149
|
+
puts "will not notify, preference for :github_preferences[:notify_about_assignment] is not true"
|
150
|
+
return response
|
151
|
+
end
|
152
|
+
|
117
153
|
puts "#{assignee} determined as the assignee."
|
118
154
|
|
119
|
-
url = body[type][
|
155
|
+
url = body[type]["html_url"]
|
120
156
|
|
121
157
|
message = "*Heads up!* You've been assigned to review a #{type.tr('_', ' ')}:\n#{url}"
|
122
158
|
|
@@ -126,17 +162,49 @@ module Lita
|
|
126
162
|
response
|
127
163
|
end
|
128
164
|
|
165
|
+
def act_on_review_requested(body, response)
|
166
|
+
puts "Detected a review request."
|
167
|
+
|
168
|
+
reviewers = body["pull_request"]["requested_reviewers"]
|
169
|
+
|
170
|
+
reviewers.each do |reviewer|
|
171
|
+
engineer = find_engineer(github: reviewer["login"])
|
172
|
+
|
173
|
+
if engineer
|
174
|
+
puts "#{engineer} determined as a reviewer."
|
175
|
+
|
176
|
+
puts "Looking up preferences..."
|
177
|
+
should_notify = engineer[:github_preferences][:notify_about_review_requests]
|
178
|
+
|
179
|
+
if !should_notify
|
180
|
+
puts "will not notify, preference for :github_preferences[:notify_about_review_requests] is not true"
|
181
|
+
else
|
182
|
+
url = body["pull_request"]["html_url"]
|
183
|
+
|
184
|
+
message = "You've been asked to review a pull request:\n#{url}"
|
185
|
+
|
186
|
+
puts "Sending DM to #{engineer}..."
|
187
|
+
send_dm(engineer[:usernames][:slack], message)
|
188
|
+
end
|
189
|
+
else
|
190
|
+
puts "Could not find engineer #{reviewer["login"]}"
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
response
|
195
|
+
end
|
196
|
+
|
129
197
|
def act_on_pr_labeled(body, response)
|
130
198
|
type = detect_type(body)
|
131
199
|
puts "Detected that someone labeled a #{type.tr('_', ' ')}."
|
132
200
|
|
133
201
|
if type.nil?
|
134
|
-
puts
|
202
|
+
puts "Neither pull request or issue detected, exiting..."
|
135
203
|
return
|
136
204
|
end
|
137
205
|
|
138
206
|
if body["pull_request"]["labels"].none? { |label| label["name"].downcase.include?('review') }
|
139
|
-
puts
|
207
|
+
puts "Labels do not include a review label, exiting..."
|
140
208
|
return
|
141
209
|
end
|
142
210
|
|
@@ -155,7 +223,7 @@ module Lita
|
|
155
223
|
|
156
224
|
puts "#{chosen_reviewer} determined as the reviewer."
|
157
225
|
|
158
|
-
url = body[type][
|
226
|
+
url = body[type]["html_url"]
|
159
227
|
|
160
228
|
message_for_reviewer = "You're next in line to review a PR! Please review, or assign to an engineer with more context if you think you are unable to give a thorough review. \n#{url}"
|
161
229
|
message_for_owner = "#{chosen_reviewer} has been notified via round-robin to review #{body["pull_request"]["html_url"]}"
|
@@ -211,8 +279,8 @@ module Lita
|
|
211
279
|
|
212
280
|
# get each @mentioned engineer in the comment
|
213
281
|
mentions = comment
|
214
|
-
.split(
|
215
|
-
.map { |snip| snip.split(
|
282
|
+
.split("@")[1..-1] # "a @b @c d" => ["b ", "c d"]
|
283
|
+
.map { |snip| snip.split(" ").first } # ["b ", "c d"] => ["b", "c"]
|
216
284
|
.map { |name| name.gsub(/[^0-9a-z\-_]/i, '') }
|
217
285
|
|
218
286
|
puts "Done. Got #{mentions}"
|
@@ -310,10 +378,10 @@ module Lita
|
|
310
378
|
end
|
311
379
|
|
312
380
|
def detect_type(body)
|
313
|
-
if body[
|
314
|
-
|
315
|
-
elsif body[
|
316
|
-
|
381
|
+
if body["pull_request"]
|
382
|
+
"pull_request"
|
383
|
+
elsif body["issue"]
|
384
|
+
"issue"
|
317
385
|
end
|
318
386
|
end
|
319
387
|
end
|
data/lita-github-pinger.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-github-pinger"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.9.0"
|
4
4
|
spec.authors = ["Taylor Lapeyre"]
|
5
5
|
spec.email = ["taylorlapeyre@gmail.com"]
|
6
6
|
spec.description = "A Lita handler that detects github comment notifications and regurgitates a ping to the correct slack username."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-github-pinger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taylor Lapeyre
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.7.6
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: A Lita handler that detects github comment notifications and regurgitates
|