pghub-base 1.0.0 → 1.1.0
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/README.md +64 -2
- data/app/controllers/pghub/base/webhooks_controller.rb +28 -14
- data/lib/pghub/base/version.rb +1 -1
- data/lib/pghub/config.rb +6 -1
- data/lib/pghub/github_api/comment.rb +1 -1
- data/lib/pghub/github_api/connection.rb +1 -1
- data/lib/pghub/github_api/issue.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: f245a5fb1c868d0c633a8972343632fa85c26323
|
4
|
+
data.tar.gz: ab2a12286599851948998da7ea08472523c5a2ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a35be0334d6b3feb3dada33a9d9b1762182c3d1ca8d5ca47dbe644f250de50f9632c744609ef1f61f0ba96b25018e2bc238ba75b5fccec22d85652a17844543
|
7
|
+
data.tar.gz: 66c4207b01205d9623459f7d3a978caf326b66e60a04e1b4b840f5ddc6a1905eecb3d3ffb06c6a19630970543a69fb7c61291bd658133b9e8283e2e7be73f1e6
|
data/README.md
CHANGED
@@ -1,14 +1,76 @@
|
|
1
1
|
# Pghub::Base
|
2
2
|
This gem offers base function for all `Pghub` gems.
|
3
3
|
|
4
|
-
[
|
4
|
+
[pghub-lgtm](https://github.com/playground-live/pghub-lgtm)
|
5
5
|
|
6
|
-
[
|
6
|
+
[pghub-issue_title](https://github.com/playground-live/pghub-issue_title)
|
7
|
+
|
8
|
+
[pghub-auto_assign](https://github.com/playground-live/pghub-auto_assign)
|
7
9
|
|
8
10
|
## Usage
|
9
11
|
You don't have to operate this gem.
|
10
12
|
Look at other `Pghub` gems.
|
11
13
|
|
14
|
+
### Get github access token
|
15
|
+
|
16
|
+
### Deploy to heroku
|
17
|
+
|
18
|
+
### All Pghub gems (lgtm, issue\_title, auto\_assign)
|
19
|
+
|
20
|
+
[](https://heroku.com/deploy?template=https://github.com/playground-live/pghub-server)
|
21
|
+
|
22
|
+
### Pghub-lgtm
|
23
|
+
|
24
|
+
[](https://heroku.com/deploy?template=https://github.com/playground-live/pghub-server/tree/lgtm)
|
25
|
+
|
26
|
+
### Pghub-issue_title
|
27
|
+
|
28
|
+
[](https://heroku.com/deploy?template=https://github.com/playground-live/pghub-server/tree/issue_title)
|
29
|
+
|
30
|
+
### Pghub-auto_assign
|
31
|
+
|
32
|
+
[](https://heroku.com/deploy?template=https://github.com/playground-live/pghub-server/tree/auto_assign)
|
33
|
+
|
34
|
+
### Deploy manually
|
35
|
+
- mount in routes.rb
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
mount Pghub::Base::Engine => 'some/path'
|
39
|
+
```
|
40
|
+
|
41
|
+
- Add following settings to config/initializers/pghub.rb
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
Pghub.configure do |config|
|
45
|
+
config.github_organization = "Your organization (or user) name"
|
46
|
+
config.github_access_token = "Your Github Access Token"
|
47
|
+
#for auto_assign
|
48
|
+
config.num_of_assignees_per_team = { your_team_name: 1, your_team_name2: 1 }
|
49
|
+
config.num_of_reviewers_per_team = { your_team_name: 2, your_team_name2: 2 }
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
53
|
+
- Deploy to server
|
54
|
+
|
55
|
+
|
56
|
+
### Set webhook to your repository
|
57
|
+
|
58
|
+
|||
|
59
|
+
|:-:|:-:|
|
60
|
+
|URL|heroku'sURL/github_webhooks or heroku'sURL/some/path|
|
61
|
+
|Content-Type|application/json|
|
62
|
+
|Secret||
|
63
|
+
|event|check the following events|
|
64
|
+
|
65
|
+
#### events
|
66
|
+
- commit comment
|
67
|
+
- issue comment
|
68
|
+
- issues
|
69
|
+
- pull request
|
70
|
+
- pull request comment
|
71
|
+
- pull request review comment
|
72
|
+
|
73
|
+
|
12
74
|
## Installation
|
13
75
|
Add this line to your application's Gemfile:
|
14
76
|
|
@@ -2,7 +2,6 @@ require_dependency "pghub/base/application_controller"
|
|
2
2
|
|
3
3
|
module Pghub::Base
|
4
4
|
class WebhooksController < ApplicationController
|
5
|
-
@webhook_params = nil
|
6
5
|
VALID_ACTIONS = %w[
|
7
6
|
opened
|
8
7
|
edited
|
@@ -13,9 +12,7 @@ module Pghub::Base
|
|
13
12
|
].freeze
|
14
13
|
|
15
14
|
def create
|
16
|
-
|
17
|
-
|
18
|
-
return unless VALID_ACTIONS.include?(@webhook_params[:action])
|
15
|
+
return unless VALID_ACTIONS.include?(action)
|
19
16
|
|
20
17
|
if defined? Pghub::Lgtm
|
21
18
|
Pghub::Lgtm.post(issue_path) if input.include?('LGTM')
|
@@ -25,26 +22,43 @@ module Pghub::Base
|
|
25
22
|
Pghub::IssueTitle.post(issue_path, input) if input.include?('ref')
|
26
23
|
end
|
27
24
|
|
25
|
+
if defined? Pghub::AutoAssign
|
26
|
+
Pghub::AutoAssign.post(issue_path, opened_pr_user) if action == 'opened'
|
27
|
+
end
|
28
|
+
|
28
29
|
head 200
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
32
33
|
|
34
|
+
def action
|
35
|
+
params[:webhook][:action]
|
36
|
+
end
|
37
|
+
|
38
|
+
def webhook_params
|
39
|
+
@webhook_params ||=
|
40
|
+
if params[:webhook][:comment]
|
41
|
+
params[:webhook][:comment]
|
42
|
+
elsif params[:webhook][:review]
|
43
|
+
params[:webhook][:review]
|
44
|
+
elsif params[:webhook][:issue]
|
45
|
+
params[:webhook][:issue]
|
46
|
+
else
|
47
|
+
params[:webhook][:pull_request]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
33
51
|
def input
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
@webhook_params[:issue][:body]
|
40
|
-
else
|
41
|
-
@webhook_params[:pull_request][:body]
|
42
|
-
end
|
52
|
+
webhook_params[:body]
|
53
|
+
end
|
54
|
+
|
55
|
+
def opened_pr_user
|
56
|
+
webhook_params[:user][:login]
|
43
57
|
end
|
44
58
|
|
45
59
|
def issue_path
|
46
60
|
reg_organization = %r{#{Pghub.config.github_organization}\/}
|
47
|
-
path =
|
61
|
+
path = params[:webhook][:issue].present? ? params[:webhook][:issue][:url] : params[:webhook][:pull_request][:issue_url]
|
48
62
|
|
49
63
|
path.match(reg_organization).post_match
|
50
64
|
end
|
data/lib/pghub/base/version.rb
CHANGED
data/lib/pghub/config.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
module Pghub
|
2
2
|
class Config
|
3
|
-
attr_accessor :github_organization,
|
3
|
+
attr_accessor :github_organization,
|
4
|
+
:github_access_token,
|
5
|
+
:num_of_assignees_per_team,
|
6
|
+
:num_of_reviewers_per_team
|
4
7
|
|
5
8
|
def initialize
|
6
9
|
@github_organization = ''
|
7
10
|
@github_access_token = ''
|
11
|
+
@num_of_assignees_per_team = {}
|
12
|
+
@num_of_reviewers_per_team = {}
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
@@ -7,7 +7,7 @@ class GithubAPI
|
|
7
7
|
|
8
8
|
def post(content)
|
9
9
|
connection.post do |req|
|
10
|
-
req.url "
|
10
|
+
req.url "/repos/#{Pghub.config.github_organization}/#{issue_path}/comments?access_token=#{Pghub.config.github_access_token}"
|
11
11
|
req.headers['Content-Type'] = 'application/json'
|
12
12
|
req.body = { body: content }.to_json
|
13
13
|
end
|
@@ -4,7 +4,7 @@ require 'faraday'
|
|
4
4
|
class GithubAPI
|
5
5
|
module Connection
|
6
6
|
def connection
|
7
|
-
Faraday.new(url:
|
7
|
+
Faraday.new(url: 'https://api.github.com',
|
8
8
|
ssl: { verify: true }) do |faraday|
|
9
9
|
faraday.request :multipart
|
10
10
|
faraday.request :url_encoded
|
@@ -13,7 +13,7 @@ class GithubAPI
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def issue_response
|
16
|
-
response = connection.get("
|
16
|
+
response = connection.get("/repos/#{Pghub.config.github_organization}/#{issue_path}?access_token=#{Pghub.config.github_access_token}")
|
17
17
|
JSON.parse(response.body)
|
18
18
|
end
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pghub-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ebkn12, akias, Doppon, seteen, mryoshio, sughimura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|