14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/see/plugins/github.rb', line 14
def run(config, plugin_config)
info = []
token = ENV['GITHUB_ACCESS_TOKEN']
unless token
info << " You must set GITHUB_ACCESS_TOKEN env variable".red
return info
end
client = Octokit::Client.new :access_token => token
account = plugin_config['account']
repository = plugin_config['repository']
github_name = [account, repository].join '/'
pull_requests = client.pull_requests(github_name)
if pull_requests.count > 0
info << " Open pull requests:".light_blue
pull_requests.each do |pull_request|
username = "[#{pull_request.user.login}]".cyan
time = "- #{pull_request.updated_at.strftime("%b %e,%l:%M %p")}".black
info << " - #{pull_request.title} #{username} #{time}"
end
else
info << " No open pull requests".yellow
end
issues = client.issues(github_name)
if issues.count > 0
info << " Open issues:".light_blue
issues.each do |issue|
username = "[#{issue.user.login}]".cyan
time = "- #{issue.updated_at.strftime("%b %e,%l:%M %p")}".black
info << " - #{issue.title} #{username} #{time}"
end
else
info << "No open issues".yellow
end
info
end
|