tokite 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/app/controllers/tokite/hooks_controller.rb +3 -3
- data/app/models/tokite/hook.rb +5 -5
- data/app/models/tokite/hook_event/pull_request.rb +4 -4
- data/app/models/tokite/rule.rb +7 -7
- data/app/views/tokite/rules/_form.html.haml +1 -1
- data/lib/tokite/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2fe3544c3670e931721a0ce647c8b09db335835
|
4
|
+
data.tar.gz: 6ac94d96a79fa5fdaa76d81dedcdeb1c9bfb5e84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46491fa456724eb6a327a35b5aca39cabca50975df29f892e390a39b13f2f749aa7d750e220801bfce026f0a63ac0de021b6fefce5e37e424bbf91d6d8a5348a
|
7
|
+
data.tar.gz: 492a5efb83efa8139efc8740250ac4f21c9a603df4bbfb845425b041cc592cbb7141268b775da0c008965efd3b6326ba1262cb0bcc791b29896685eb4af87b51
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Tokite [![CircleCI](https://circleci.com/gh/
|
1
|
+
# Tokite [![CircleCI](https://circleci.com/gh/cookpad/tokite.svg?style=svg)](https://circleci.com/gh/cookpad/tokite) [![Gem Version](https://badge.fury.io/rb/tokite.svg)](https://badge.fury.io/rb/tokite)
|
2
2
|
|
3
3
|
Tokite send GitHub event (pull-request, issue and comment) to Slack.
|
4
4
|
|
@@ -23,8 +23,9 @@ end
|
|
23
23
|
### Setup database
|
24
24
|
```console
|
25
25
|
$ ./bin/rails db:create
|
26
|
-
$ ./bin/rails tokite:ridgepole:install
|
27
|
-
$ ./bin/rails tokite:ridgepole:apply
|
26
|
+
$ ./bin/rails app:tokite:ridgepole:install
|
27
|
+
$ ./bin/rails app:tokite:ridgepole:apply
|
28
|
+
$ RAILS_ENV=test ./bin/rails app:tokite:ridgepole:apply
|
28
29
|
```
|
29
30
|
|
30
31
|
### Setup yarn pkg
|
@@ -67,7 +68,7 @@ Tokite support only below events now.
|
|
67
68
|
|
68
69
|
<table>
|
69
70
|
<tr><th>Name</th><th>Description</th><th>Example</th></tr>
|
70
|
-
<tr><td>repo:</td><td>Match repository name.</td><td>repo:
|
71
|
+
<tr><td>repo:</td><td>Match repository name.</td><td>repo:cookpad/tokite</td></tr>
|
71
72
|
<tr><td>title:</td><td>Match pull_request or issues title.</td><td>title:Bug</td></tr>
|
72
73
|
<tr><td>event:</td><td>Match event type pull_request, issues, issue_comment, pull_request_review, pull_request_review_comment.</td><td>event:/pull_request|issues|pull_request_review|pull_request_review_comment/</td></tr>
|
73
74
|
<tr><td>body:</td><td>Match body text.</td><td>body:"review please"</td></tr>
|
@@ -3,15 +3,15 @@
|
|
3
3
|
module Tokite
|
4
4
|
class HooksController < ActionController::API
|
5
5
|
GITHUB_EVENT_HEADER = "X-GitHub-Event"
|
6
|
-
|
6
|
+
|
7
7
|
def create
|
8
8
|
logger.debug("Hook triggered: #{github_event}")
|
9
9
|
Hook.fire!(github_event, request.request_parameters)
|
10
10
|
render plain: "ok"
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
private
|
14
|
-
|
14
|
+
|
15
15
|
def github_event
|
16
16
|
request.headers[GITHUB_EVENT_HEADER]
|
17
17
|
end
|
data/app/models/tokite/hook.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Tokite
|
2
2
|
class Hook
|
3
3
|
attr_reader :event
|
4
|
-
|
4
|
+
|
5
5
|
HOOK_EVENTS = {
|
6
6
|
"pull_request" => HookEvent::PullRequest,
|
7
7
|
"issues" => HookEvent::Issues,
|
@@ -9,16 +9,16 @@ module Tokite
|
|
9
9
|
"pull_request_review" => HookEvent::PullRequestReview,
|
10
10
|
"pull_request_review_comment" => HookEvent::PullRequestReviewComment,
|
11
11
|
}.freeze
|
12
|
-
|
12
|
+
|
13
13
|
def self.fire!(github_event, hook_params)
|
14
14
|
event_class = HOOK_EVENTS[github_event]
|
15
15
|
Hook.new(event_class.new(hook_params)).fire! if event_class
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def initialize(event)
|
19
19
|
@event = event
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def fire!
|
23
23
|
return unless event.notify?
|
24
24
|
payloads = []
|
@@ -44,7 +44,7 @@ module Tokite
|
|
44
44
|
notify!(channel: payload[:channel], text: payload[:additional_text], icon_emoji: payload[:emoji], parse: "full") if payload[:additional_text].present?
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def notify!(payload)
|
49
49
|
NotifyGithubHookEventJob.perform_now(payload.compact)
|
50
50
|
end
|
@@ -10,21 +10,21 @@ module Tokite
|
|
10
10
|
user: hook_params[:pull_request][:user][:login],
|
11
11
|
}
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def notify?
|
15
15
|
%w(opened).include?(hook_params[:action])
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def slack_text
|
19
19
|
"[#{hook_params[:repository][:full_name]}] Pull request submitted by <#{hook_params[:pull_request][:user][:html_url]}|#{hook_params[:pull_request][:user][:login]}>"
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def slack_attachment
|
23
23
|
{
|
24
24
|
title: "##{hook_params[:pull_request][:number]} #{hook_params[:pull_request][:title]}",
|
25
25
|
title_link: hook_params[:pull_request][:html_url],
|
26
26
|
fallback: "#{hook_params[:pull_request][:title]}\n#{hook_params[:pull_request][:body]}",
|
27
|
-
text: hook_params[:pull_request][:body],
|
27
|
+
text: hook_params[:pull_request][:body] || "No description provided.",
|
28
28
|
color: "good",
|
29
29
|
}
|
30
30
|
end
|
data/app/models/tokite/rule.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Tokite
|
2
2
|
class Rule < ApplicationRecord
|
3
3
|
attr_reader :search_query
|
4
|
-
|
4
|
+
|
5
5
|
belongs_to :user
|
6
6
|
|
7
7
|
validates :name, presence: true
|
@@ -19,27 +19,27 @@ module Tokite
|
|
19
19
|
rule.match?(event)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def search_query
|
24
24
|
@search_query ||= SearchQuery.new(query)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def match?(event)
|
28
28
|
search_query.match?(event.fields)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def slack_attachment_fallback
|
32
32
|
"#{name} by #{user.name}"
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
def slack_attachment_text
|
36
36
|
"#{rule_name_link} (#{user_link}) "
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def rule_name_link
|
40
40
|
"<#{Tokite::Engine.routes.url_helpers.edit_rule_url(self)}|#{name}>"
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def user_link
|
44
44
|
"<#{Tokite::Engine.routes.url_helpers.user_url(user)}|#{user.name}>"
|
45
45
|
end
|
data/lib/tokite/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tokite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hogelog
|
@@ -251,7 +251,7 @@ files:
|
|
251
251
|
- schema/tokite_rules.schema
|
252
252
|
- schema/tokite_secure_user_tokens.schema
|
253
253
|
- schema/tokite_users.schema
|
254
|
-
homepage: https://github.com/
|
254
|
+
homepage: https://github.com/cookpad/tokite/
|
255
255
|
licenses:
|
256
256
|
- MIT
|
257
257
|
metadata: {}
|