lita-github-pinger 0.3.6 → 0.3.7
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/lib/lita/handlers/github_pinger.rb +24 -16
- data/lita-github-pinger.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 532eb6b451efd5fedee4eecbbbffe2b942701704
|
4
|
+
data.tar.gz: c0de7f549078d94d25e5f021b9d0131957d2e120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad21d6f34d595e9f50a1a099cae63b248ac52316c1c8c977534ded78c1a301dff9b9fb54bb66cc8a8ed461202cdc0baa41abec7c703b4009370ed4d321a1875
|
7
|
+
data.tar.gz: ac6abe1e6963aea188aa9fadf88c735732d668dfe4175ba459816f73dbd704f0620b1f248b8c1bddc6816da3c294d623e4491b86ba7240f9a1236f8ac4878945
|
@@ -12,32 +12,34 @@ module Lita
|
|
12
12
|
body = MultiJson.load(request.body)
|
13
13
|
|
14
14
|
if body["comment"]
|
15
|
+
thing = body["pull_request"] || body["issue"]
|
16
|
+
pr_url = thing["html_url"]
|
17
|
+
comment = body["comment"]["body"]
|
18
|
+
commenter = body["comment"]["user"]["login"]
|
15
19
|
|
16
|
-
|
20
|
+
# automatically include the creator of the PR
|
21
|
+
usernames_to_ping = [thing["user"]["login"]]
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
23
|
+
# Is anyone mentioned in this comment?
|
24
|
+
if comment.include?("@")
|
25
|
+
# get each @mentioned username in the comment
|
26
|
+
mentions = comment.split("@")[1..-1].map { |snip| snip.split(" ").first }
|
22
27
|
|
23
|
-
|
24
|
-
|
25
|
-
end.first[:slack]
|
28
|
+
# add them to the list of usernames to ping
|
29
|
+
usernames_to_ping = usernames_to_ping.concat(mentions).uniq
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
end
|
31
|
+
# slackify all of the users
|
32
|
+
usernames_to_ping.map! { |user| github_username_to_slack_username(user) }
|
33
|
+
end
|
30
34
|
|
31
35
|
message = "New PR comment from #{commenter}:\n"
|
32
|
-
message += "#{pr_url}\n
|
33
|
-
|
34
|
-
puts "Got a comment on something, sending message to #{pr_owner}"
|
36
|
+
message += "#{pr_url}\n#{comment}"
|
35
37
|
|
36
|
-
|
38
|
+
puts "Got a comment on something, sending messages to #{usernames_to_ping}"
|
37
39
|
|
40
|
+
usernames_to_ping.each { |user| send_dm(user, message) }
|
38
41
|
end
|
39
42
|
|
40
|
-
|
41
43
|
response
|
42
44
|
end
|
43
45
|
|
@@ -47,6 +49,12 @@ module Lita
|
|
47
49
|
robot.send_message(source, message)
|
48
50
|
end
|
49
51
|
|
52
|
+
def github_username_to_slack_username(github_username)
|
53
|
+
config.engineers.select do |eng|
|
54
|
+
eng[:github] == github_username
|
55
|
+
end.first[:slack]
|
56
|
+
end
|
57
|
+
|
50
58
|
def send_dm(username, content)
|
51
59
|
if user = Lita::User.fuzzy_find(username)
|
52
60
|
source = Lita::Source.new(user: user)
|
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.
|
3
|
+
spec.version = "0.3.7"
|
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."
|