ruboty-github_assignor 0.0.1 → 0.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f189154d3633ba2c3bf0e70cea9234251b43bd
|
4
|
+
data.tar.gz: cd236b8776e7579ac0704c1abe5c7e75e0d7fe2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9ce12f320ee1d3c2ad2fe06ab1b9fd855161b68e1e48a33082bf05907c3d189fd3d588363835913ebbf88ab90095cc0650120b54f900121bcdf417fc0f54dfc
|
7
|
+
data.tar.gz: dde4baa295adf27d5cedd7fdb1178b2c28a1bae47d837c4619a80cdc4a0b69bef6c7b82f5878bf1d51a256f8e62f3b702aba67eb1c9b4987b3b1552857eeb075
|
@@ -7,5 +7,12 @@ require "ruboty/handlers/github_assignor"
|
|
7
7
|
module Ruboty
|
8
8
|
module GithubAssignor
|
9
9
|
# Your code goes here...
|
10
|
+
|
11
|
+
def self.log(msg)
|
12
|
+
Ruboty.logger.info "[github_assignor] #{msg}"
|
13
|
+
|
14
|
+
# FIX thix dirty hack.
|
15
|
+
Ruboty.logger.instance_variable_get(:@logdev).dev.flush
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
@@ -16,19 +16,28 @@ module Ruboty
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def check_issues(assign = true)
|
19
|
+
log "Checking new issues..."
|
20
|
+
|
19
21
|
@octokit.issues(@repo).each do |issue|
|
20
22
|
unless @checked_issue_ids.include?(issue[:id])
|
23
|
+
log "New issue found (#{issue[:id]} / #{issue[:title]})"
|
21
24
|
if assign && !issue[:assignee]
|
22
25
|
# assign this issue
|
23
26
|
assignee = @assignor.next
|
27
|
+
log "Assigning this issue to #{assignee}..."
|
24
28
|
|
29
|
+
log "Updating assignee of GitHub issue..."
|
25
30
|
@octokit.update_issue(@repo, issue[:number], assignee: assignee.github_name)
|
31
|
+
|
32
|
+
log "Reminding the user of the issue..."
|
26
33
|
say(<<-EOC)
|
27
34
|
@#{assignee.chat_name} さん、お願いします!
|
28
35
|
|
29
36
|
#{issue[:title]}
|
30
37
|
<#{issue[:html_url]}>
|
31
38
|
EOC
|
39
|
+
|
40
|
+
log "Done."
|
32
41
|
end
|
33
42
|
@checked_issue_ids << issue[:id]
|
34
43
|
end
|
@@ -37,9 +46,14 @@ module Ruboty
|
|
37
46
|
|
38
47
|
def start(interval)
|
39
48
|
Thread.start do
|
49
|
+
log "Start watching issues"
|
40
50
|
loop do
|
41
51
|
sleep(interval)
|
42
|
-
|
52
|
+
begin
|
53
|
+
check_issues
|
54
|
+
rescue => err
|
55
|
+
log err.inspect
|
56
|
+
end
|
43
57
|
end
|
44
58
|
end
|
45
59
|
end
|
@@ -53,6 +67,7 @@ module Ruboty
|
|
53
67
|
nil
|
54
68
|
end
|
55
69
|
|
70
|
+
log "#{@from} -> #{@to}"
|
56
71
|
@robot.say(
|
57
72
|
body: body,
|
58
73
|
from: from,
|
@@ -60,6 +75,10 @@ module Ruboty
|
|
60
75
|
original: {type: "groupchat"},
|
61
76
|
)
|
62
77
|
end
|
78
|
+
|
79
|
+
def log(msg)
|
80
|
+
GithubAssignor.log("[#{@repo}] #{msg}")
|
81
|
+
end
|
63
82
|
end
|
64
83
|
end
|
65
84
|
end
|
@@ -19,18 +19,22 @@ module Ruboty
|
|
19
19
|
octokit = Octokit::Client.new(access_token: ENV['GITHUB_TOKEN'])
|
20
20
|
|
21
21
|
data = JSON.parse(ENV['GITHUB_ASSIGNOR_REPOS'])
|
22
|
+
Ruboty::GithubAssignor.log(data)
|
23
|
+
|
22
24
|
data.each do |datum|
|
23
25
|
repo = datum['repo']
|
24
26
|
to = datum['to']
|
25
|
-
|
27
|
+
assignees = datum['assignees'].map {|assignee| Hash[assignee.map {|k, v| [k.to_sym, v] }] }
|
28
|
+
assignor = Ruboty::GithubAssignor::Assignor.new(assignees)
|
26
29
|
|
27
|
-
Ruboty::GithubAssignor::RepoWatcher.new(
|
30
|
+
watcher = Ruboty::GithubAssignor::RepoWatcher.new(
|
28
31
|
robot: robot,
|
29
32
|
repo: repo,
|
30
33
|
octokit: octokit,
|
31
34
|
assignor: assignor,
|
32
35
|
to: to,
|
33
|
-
)
|
36
|
+
)
|
37
|
+
watcher.start((ENV['GITHUB_ASSIGNOR_INTERVAL'] || 60).to_i)
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|