lita-github-pinger 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/github_pinger.rb +37 -6
- 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: 86fdffcf6c595d041202bf131f3131e36c45abc2
|
4
|
+
data.tar.gz: 60bf57e40b1c281c48cf5d89e76b4a3eae9456e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cddff5c4b5995d2da602c27df3e25617065e39fd10d8ef273fe01862bcf532c63ec7f73a23251b87fdb6f00d733c7e6e3847f74af45589ad6e512fd7f969335
|
7
|
+
data.tar.gz: 9b7cc2cf54c7a6508cdaeb16fd88ca8ad3417ea9b8d8163365d023312ad3eb6a3a19bd6c029b55de68b4180a340234d9b1763d713d99cd1a3c8f7f2df8af69fc
|
@@ -7,36 +7,60 @@ module Lita
|
|
7
7
|
http.post("/ghping", :ghping)
|
8
8
|
|
9
9
|
def ghping(request, response)
|
10
|
+
|
11
|
+
puts "######################################"
|
12
|
+
puts "GitHub hook received. Parsing body... "
|
13
|
+
|
10
14
|
body = MultiJson.load(request.body)
|
11
15
|
|
16
|
+
print "Done."
|
17
|
+
puts "######################################"
|
18
|
+
|
12
19
|
if body["comment"]
|
20
|
+
puts "Detected a comment. Extracting data... "
|
21
|
+
|
13
22
|
thing = body["pull_request"] || body["issue"]
|
14
23
|
pr_url = thing["html_url"]
|
15
24
|
comment = body["comment"]["body"]
|
16
|
-
commenter =
|
25
|
+
commenter = body["comment"]["user"]["login"]
|
26
|
+
pr_owner = thing["user"]["login"]
|
27
|
+
|
28
|
+
puts "Found PR #{pr_url}"
|
29
|
+
puts "Found commenter #{commenter}"
|
30
|
+
puts "Found pr owner #{pr_owner}"
|
17
31
|
|
18
32
|
usernames_to_ping = []
|
19
33
|
# automatically include the creator of the PR, unless he's
|
20
34
|
# commenting on his own PR
|
21
|
-
if
|
22
|
-
|
35
|
+
if commenter != pr_owner
|
36
|
+
puts "Commenter is not the pr owner. Adding to list of usernames to ping."
|
37
|
+
usernames_to_ping << pr_owner
|
23
38
|
end
|
24
39
|
|
40
|
+
puts "So far, github usernames to ping: #{usernames_to_ping}"
|
25
41
|
|
26
42
|
# Is anyone mentioned in this comment?
|
27
43
|
if comment.include?("@")
|
44
|
+
puts "Found @mentions in the body of the comment! Extracting usernames... "
|
45
|
+
|
28
46
|
# get each @mentioned username in the comment
|
29
47
|
mentions = comment.split("@")[1..-1].map { |snip| snip.split(" ").first }
|
48
|
+
print "Done. (Got #{mentions})"
|
30
49
|
|
31
50
|
# add them to the list of usernames to ping
|
32
51
|
usernames_to_ping = usernames_to_ping.concat(mentions).uniq
|
33
52
|
end
|
34
53
|
|
54
|
+
puts "New list of github usernames to ping: #{usernames_to_ping}."
|
55
|
+
puts "Converting github usernames to slack usernames... "
|
56
|
+
|
35
57
|
# slackify all of the users
|
36
58
|
usernames_to_ping.map! { |user| github_to_slack_username(user) }
|
37
59
|
|
38
|
-
|
39
|
-
|
60
|
+
print "Done. (Got #{usernames_to_ping})"
|
61
|
+
|
62
|
+
puts "Starting pinging process for each engineer..."
|
63
|
+
usernames_to_ping.compact.each do |user|
|
40
64
|
|
41
65
|
pref = find_engineer(slack: user)[:preference]
|
42
66
|
case pref
|
@@ -53,15 +77,19 @@ module Lita
|
|
53
77
|
end
|
54
78
|
|
55
79
|
end
|
80
|
+
|
81
|
+
puts "GitHub Hook successfully processed."
|
56
82
|
end
|
57
83
|
|
58
84
|
response
|
59
85
|
end
|
60
86
|
|
61
87
|
def alert_eng_pr(message)
|
88
|
+
puts "Alerting #eng-pr about content #{message[0..5]}... "
|
62
89
|
room = Lita::Room.fuzzy_find("eng-pr")
|
63
90
|
source = Lita::Source.new(room: room)
|
64
91
|
robot.send_message(source, message)
|
92
|
+
puts "Done."
|
65
93
|
end
|
66
94
|
|
67
95
|
def find_engineer(slack: nil, github: nil)
|
@@ -75,13 +103,16 @@ module Lita
|
|
75
103
|
end
|
76
104
|
|
77
105
|
def github_to_slack_username(github_username)
|
78
|
-
find_engineer(github: github_username)
|
106
|
+
engineer = find_engineer(github: github_username)
|
107
|
+
engineer[:slack] if engineer
|
79
108
|
end
|
80
109
|
|
81
110
|
def send_dm(username, content)
|
111
|
+
puts "Sending DM to #{username} with content #{content[0..5]}... "
|
82
112
|
if user = Lita::User.fuzzy_find(username)
|
83
113
|
source = Lita::Source.new(user: user)
|
84
114
|
robot.send_message(source, content)
|
115
|
+
print "Done."
|
85
116
|
else
|
86
117
|
alert_eng_pr("Could not find user with name #{username}, please configure everbot.")
|
87
118
|
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.4.
|
3
|
+
spec.version = "0.4.4"
|
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."
|