lita-github-pinger 0.1.5 → 0.1.6

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: 3b5e3bf8f9557663e6b1fcc9cd891aca132f4dfe
4
- data.tar.gz: aff9d9747cde46cab4e86b6fae38e0cdcada32cf
3
+ metadata.gz: 7ec059d6207155788e7c6b5e118aab41d182e17a
4
+ data.tar.gz: 5e30bc5beba43aa299bda1b4f63e88b0491bf73a
5
5
  SHA512:
6
- metadata.gz: 464979d993761a7c2a91d9a3ab13cff69804ca6e810cf37df879f97cc6f81c68d2377afb4281b05092548193a4e7002a1521100fb2a965f48721d230ec588f85
7
- data.tar.gz: 3b3b5fa464d9cebf2bcb52cf0c344499330d0c9989801411ec493302e209f4a1b0a29922bdaa5723c423229770ee21a4fb7b309ddfb8f2c01c91fc836c970f40
6
+ metadata.gz: e8649f1a775c5771c91b8282a18eb764a97617fbfc4eb9005325755316420d1b9778a70b8c96dbc5a4161fe4a0ebf732d994596366b5736be98af4205607ef95
7
+ data.tar.gz: e0ce2f411d54b209f06fff49e5acffb83a1908bd4d5ce09c699a62e4c17029dcd86bcbf9acf2f0a2ab0654e205b40919113fa9411a54bebd104bc9082c74f7a1
@@ -2,21 +2,32 @@ 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
+
5
7
  config :engineers, type: Array, required: true
6
8
 
7
- route(/@(\w*)/, :detect_comment, command: false)
9
+ route(GITHUB_PR_COMMENT_REGEX, :detect_comment, command: false)
8
10
 
9
11
  def detect_comment(message)
10
- return unless message.user.metadata["name"] == "" # Integrations don't have names
11
- mentioned_username = message.matches[0][0]
12
+ pr_id,
13
+ pr_title,
14
+ assigned_person,
15
+ comment_author,
16
+ comment_text = message.matches[0]
12
17
 
13
- # side effects intentional
14
- found = config.engineers.any? do |eng|
15
- message.reply("@" + eng[:slack]) if eng[:github] == mentioned_username
16
- end
18
+ # return unless message.user.metadata["name"] == "" # Integrations don't have names
19
+ return unless comment_text.include?("@")
20
+
21
+ mentioned_username = comment_text.split("@")[1].split(" ").first
17
22
 
18
- unless found
19
- message.reply("Could not find a slack username for #{pr_owner}. Please configure everbot to include this username.")
23
+ config.engineers.each do |engineer|
24
+ if engineer[:github] == mentioned_username
25
+ content = %Q{#{engineer[:slack]}, you were mentioned by #{comment_author}:
26
+ http://github.com/everlane/everlane.com/pulls/#{pr_id}
27
+ > #{comment_text}
28
+ }
29
+ message.reply(content)
30
+ end
20
31
  end
21
32
  end
22
33
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-github-pinger"
3
- spec.version = "0.1.5"
3
+ spec.version = "0.1.6"
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,7 +43,14 @@ describe Lita::Handlers::GithubPinger, lita_handler: true do
43
43
  end
44
44
 
45
45
  it "will respond" do
46
- send_message("comments up @taylorlapeyre)")
47
- expect(replies.count).to eq 0
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/pulls/1137
53
+ > @taylorlapeyre hai
54
+ }
48
55
  end
49
56
  end
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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lapeyre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-04 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita