lita-github-pinger 0.1.8 → 0.1.9

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
  SHA1:
3
- metadata.gz: 80370f63b75bbc667a90e4e9b353a945da00858f
4
- data.tar.gz: 6a73783bf7382617242f7cb13e79bd7822575d76
3
+ metadata.gz: 3a3d82bf0baafe7a5419a8f82de49e1cedc3e5ff
4
+ data.tar.gz: 0f0b885ce1c21b95462c6336d89c3b9dfb0dc1cf
5
5
  SHA512:
6
- metadata.gz: 0815ed89a5a02f549e0432ee4e6c4d5002818fbf28caec746449787a21f404f24e09f237ff473e6e0f20951a1df2c7c421ecfc1f5fee83404f647dabf3b3018d
7
- data.tar.gz: 497b7e93bd042edfefe945d314b3b9be456e9c0c0d985d3484662205386b85ffdea6b43c39f7277b82b306378b7941fffe6e8d0252c724caceb772930ed372ed
6
+ metadata.gz: 6638e2a20b0350ebe248f20162c423eda4733f1e8eb956429bf4c754633b458bfba191ef75dbf296315af42e8756461e38d1cdfcf252ff23861ccbcfb242c9a6
7
+ data.tar.gz: b5a60325b56f1bb91c76cc7e050a67a4c6c3e945a62583ddaa4caf911b0e21a08fa3e46b24d0c14fa83cecda8bd3814ca1c1c1bfcde2e0394fe8bd2a3e6809d3
@@ -2,40 +2,25 @@ module Lita
2
2
  module Handlers
3
3
  class GithubPinger < Handler
4
4
 
5
- GITHUB_PR_COMMENT_REGEX = /\[Everlane\/.*\] New comment on pull request #(\d+): (.+) \(assigned to (\w+)\)\nComment by (\w+)\n(.*)/
6
-
7
5
  config :engineers, type: Array, required: true
8
6
 
9
- route(GITHUB_PR_COMMENT_REGEX, :detect_comment, command: false)
10
- route(/testing/, :see_what_happens, command: false)
11
-
12
- def see_what_happens(message)
13
- message.reply message.message.body
14
- end
7
+ route(/@(\w*)/, :detect_comment, command: false)
15
8
 
16
9
  def detect_comment(message)
17
- pr_id,
18
- pr_title,
19
- assigned_person,
20
- comment_author,
21
- comment_text = message.matches[0]
22
-
23
- # return unless message.user.metadata["name"] == "" # Integrations don't have names
24
- return unless comment_text.include?("@")
10
+ return unless message.user.metadata["name"] == "" # Integrations don't have names
11
+ mentioned_username = message.matches[0][0]
25
12
 
26
- mentioned_username = comment_text.split("@")[1].split(" ").first
27
-
28
- config.engineers.each do |engineer|
29
- if engineer[:github] == mentioned_username
30
- content = %Q{#{engineer[:slack]}, you were mentioned by #{comment_author}:
31
- http://github.com/everlane/everlane.com/pull/#{pr_id}
32
- > #{comment_text}
33
- }
34
- message.reply(content)
13
+ # side effects intentional
14
+ found = config.engineers.any? do |eng|
15
+ if eng[:github] == mentioned_username
35
16
  user = Lita::User.find_by_name(engineer[:slack])
36
- robot.send_message(user, content)
17
+ robot.send_message(user, "New PR comment! #{message.message.body}")
37
18
  end
38
19
  end
20
+
21
+ unless found
22
+ message.reply("Could not find a slack username for #{pr_owner}. Please configure everbot to include this username.")
23
+ end
39
24
  end
40
25
  end
41
26
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-github-pinger"
3
- spec.version = "0.1.8"
3
+ spec.version = "0.1.9"
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."
@@ -43,14 +43,7 @@ describe Lita::Handlers::GithubPinger, lita_handler: true do
43
43
  end
44
44
 
45
45
  it "will respond" do
46
- send_message(%q{
47
- [Everlane/everlane.com] New comment on pull request #1137: More accurate location data and (by extension) working weather for factories (assigned to taylorlapeyre)
48
- Comment by thenanyu
49
- @taylorlapeyre hai
50
- })
51
- expect(replies.last).to eq %q{taylor, you were mentioned by thenanyu:
52
- http://github.com/everlane/everlane.com/pull/1137
53
- > @taylorlapeyre hai
54
- }
46
+ send_message("comments up @taylorlapeyre)")
47
+ expect(replies.count).to eq 0
55
48
  end
56
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-github-pinger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lapeyre