· 6 years ago · Nov 26, 2018, 03:18 AM
1#!/usr/bin/env ruby
2
3# A quick script to dump an overview of all the open issues in all my github projects
4
5require 'optparse'
6require 'octokit'
7require 'awesome_print'
8require 'rainbow'
9
10options = {
11 :login => %x[ git config --get github.user ].strip,
12 :oauth_token => %x[ git config --get github.token ].strip,
13 :labels => ''
14}
15
16client = Octokit::Client.new( options )
17
18OptionParser.new do |opts|
19 # restrict to specific label
20 opts.on('-l LABEL') { |l| options[:labels] = l }
21end.parse!(ARGV)
22
23repo_restrict_list = $*
24
25# markdown formatted output
26client.list_repos.each do |repo|
27 next if repo.fork
28 next unless repo.open_issues > 0
29 next if repo_restrict_list.size > 0 && !repo_restrict_list.include?(repo.name)
30
31 print "## Repository: "
32 puts repo.name
33
34 print "### Issue Count: "
35 puts repo.open_issues
36
37 client.list_issues( repo.full_name, per_page: 200, labels: options[:labels] ).each do |issue|
38
39 labels = []
40 if not issue.labels.empty? then
41 issue.labels.each do |l|
42 # labels << l.foreground( label_color[l] ).bright
43 labels << l["name"]
44 end
45 end
46 puts "* #{issue.title}. **Labels:** #{labels.join(', ')}"
47 end
48 puts
49end