devtools-prlist 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +25 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.rubocop.yml +1156 -0
- data/.travis.yml +5 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +34 -0
- data/Rakefile +8 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/devtools-prlist.gemspec +32 -0
- data/exe/prlist +41 -0
- data/lib/pr_list.rb +4 -0
- data/lib/pr_list/options.rb +52 -0
- data/lib/pr_list/pull_requests.rb +85 -0
- data/lib/pr_list/version.rb +4 -0
- metadata +175 -0
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Donovan Young
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/dyoung522/devtools-prlist.svg?branch=master)](https://travis-ci.org/dyoung522/devtools-prlist)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/dyoung522/devtools-prlist/badges/gpa.svg)](https://codeclimate.com/github/dyoung522/devtools-prlist)
|
3
|
+
[![Test Coverage](https://codeclimate.com/github/dyoung522/devtools-prlist/badges/coverage.svg)](https://codeclimate.com/github/dyoung522/devtools-prlist/coverage)
|
4
|
+
|
5
|
+
# PRlist
|
6
|
+
|
7
|
+
Displays a Queue of Pull Requests based on labels
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install it from the command line
|
12
|
+
|
13
|
+
$ gem install devtools-prlist
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Once installed, this gem provides the `prlist` command line utility.
|
18
|
+
|
19
|
+
Please run `prlist --help` for more information.
|
20
|
+
|
21
|
+
## Development
|
22
|
+
|
23
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
24
|
+
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
Bug reports and pull requests are welcome on [our GitHub page](https://github.com/dyoung522/devtools)
|
30
|
+
|
31
|
+
## License
|
32
|
+
|
33
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
34
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "devtools"
|
5
|
+
require "runtest"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "pry"
|
15
|
+
Pry.start
|
16
|
+
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require "pr_list/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "devtools-prlist"
|
9
|
+
spec.version = PRlist::VERSION
|
10
|
+
spec.authors = ["Donovan Young"]
|
11
|
+
spec.email = ["dyoung522@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = %q{Queries GitHub pull requests}
|
14
|
+
spec.description = %q{Queries GitHub pull requests and displays a list. Can filter based on labels}
|
15
|
+
spec.homepage = "https://github.com/dyoung522/devtools-prlist"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "config", "~> 1.3"
|
24
|
+
spec.add_dependency "octokit", "~> 4.0"
|
25
|
+
spec.add_dependency "devtools-base", "~> 2.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
30
|
+
spec.add_development_dependency "pry", "~> 0.4"
|
31
|
+
spec.add_development_dependency "factory_girl", "~> 4.0"
|
32
|
+
end
|
data/exe/prlist
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby -w
|
2
|
+
lib = File.expand_path("../../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require "pr_list"
|
6
|
+
|
7
|
+
module PRlist
|
8
|
+
begin
|
9
|
+
OptParse.parse(ARGV)
|
10
|
+
rescue RuntimeError
|
11
|
+
puts "Whoops!\n\n"
|
12
|
+
|
13
|
+
unless Options.token
|
14
|
+
puts "You didn't give us a GitHub token to authenticate with."
|
15
|
+
end
|
16
|
+
|
17
|
+
if Options.repos.nil? || Options.repos.empty?
|
18
|
+
puts "You didn't give us any GitHub repos to work with."
|
19
|
+
end
|
20
|
+
|
21
|
+
puts "\nThe easiest way to provide required information is to create a ./#{DevTools::PROGRAM}.conf file with the following content..."
|
22
|
+
puts "\ntoken: <GITHUB-TOKEN-SHA>\nrepos:\n - repo-name-1\n - repo-name-2"
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
|
26
|
+
pull_requests = PullRequests.new Options.token, Options.repos
|
27
|
+
|
28
|
+
puts "QA Queue for #{pull_requests.repos.join(", ")}\n\n" if Options.verbose > 0
|
29
|
+
|
30
|
+
pull_requests.by_date do |pr|
|
31
|
+
next unless pr.has_label?(OptParse.label_values) if Options.queue
|
32
|
+
|
33
|
+
printf "%s%s (%s) %s",
|
34
|
+
Options.markdown ? "1. " : "",
|
35
|
+
Options.markdown ? "[PR ##{pr.number}](#{pr.pull_request.html_url})" : "PR ##{pr.number}",
|
36
|
+
Options.verbose > 1 ? pr.repo : pr.repo(short: true),
|
37
|
+
pr.title
|
38
|
+
printf " (labels: %s)", pr.labels.join(", ") if Options.verbose > 2
|
39
|
+
puts
|
40
|
+
end
|
41
|
+
end
|
data/lib/pr_list.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module PRlist
|
2
|
+
class OptParse
|
3
|
+
|
4
|
+
def self.default_options
|
5
|
+
{
|
6
|
+
markdown: false,
|
7
|
+
queue: false
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.validate_options
|
12
|
+
raise RuntimeError, "Missing configuration file" if Options.nil?
|
13
|
+
raise RuntimeError, "Missing authentication token" if Options.token.nil?
|
14
|
+
raise RuntimeError, "No repositories provided" if Options.repos.empty?
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.parse(argv_opts = [], unit_testing = false)
|
18
|
+
opt_parse = DevTools::OptParse.new({ name: IDENT,
|
19
|
+
version: VERSION,
|
20
|
+
defaults: default_options,
|
21
|
+
testing: unit_testing })
|
22
|
+
|
23
|
+
parser = opt_parse.parser
|
24
|
+
|
25
|
+
parser.banner = "Usage: #{DevTools::PROGRAM} [OPTIONS]"
|
26
|
+
|
27
|
+
parser.separator ""
|
28
|
+
parser.separator "[OPTIONS]"
|
29
|
+
|
30
|
+
parser.on "-m", "--markdown", "Outputs in markdown friendly format" do
|
31
|
+
Options.markdown = true
|
32
|
+
end
|
33
|
+
|
34
|
+
parser.on "--[no-]queue", "filters PRs into a queue list for QA" do |opt|
|
35
|
+
Options.queue = opt
|
36
|
+
end
|
37
|
+
|
38
|
+
parser.separator ""
|
39
|
+
parser.separator "Common Options:"
|
40
|
+
|
41
|
+
parser.parse!(argv_opts)
|
42
|
+
|
43
|
+
validate_options unless unit_testing
|
44
|
+
|
45
|
+
Options
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.label_values
|
49
|
+
Options.labels.keys.map { |k| Options.labels[k] }.flatten.compact
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require "octokit"
|
2
|
+
|
3
|
+
module PRlist
|
4
|
+
class PullRequest
|
5
|
+
attr_reader :issue
|
6
|
+
|
7
|
+
def method_missing(method_sym, *arguments, &block)
|
8
|
+
@issue.respond_to?(method_sym) ? @issue.send(method_sym, *arguments, &block) : super
|
9
|
+
end
|
10
|
+
|
11
|
+
def respond_to_missing?(method_name, include_private = false)
|
12
|
+
@issue.respond_to?(method_name.to_sym) || super
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(issue)
|
16
|
+
@issue ||= issue
|
17
|
+
end
|
18
|
+
|
19
|
+
def date
|
20
|
+
@issue.created_at
|
21
|
+
end
|
22
|
+
|
23
|
+
def has_label?(filter_by)
|
24
|
+
labels.any? { |label| [filter_by].flatten.map { |l| l.downcase.strip }.include?(label.downcase.strip) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def labels
|
28
|
+
@issue.labels.map { |l| l.name }
|
29
|
+
end
|
30
|
+
|
31
|
+
def repo(opt = {})
|
32
|
+
opt[:short] = false unless opt.has_key?(:short)
|
33
|
+
|
34
|
+
/repos\/(\w*\/?(.*))$/.match(@issue.repository_url)[opt[:short] ? 2 : 1]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class PullRequests
|
39
|
+
attr_reader :pulls
|
40
|
+
|
41
|
+
def initialize(token = nil, repos = [])
|
42
|
+
@pulls ||= []
|
43
|
+
@github ||= __authenticate token
|
44
|
+
|
45
|
+
repos.each { |repo| load!(repo) } if authorized?
|
46
|
+
end
|
47
|
+
|
48
|
+
def authorized?
|
49
|
+
return !@github.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
def auth!(token)
|
53
|
+
@github = __authenticate token
|
54
|
+
end
|
55
|
+
|
56
|
+
def load!(repo)
|
57
|
+
raise NoAuthError, "You must authorized with github using #auth first" unless authorized?
|
58
|
+
|
59
|
+
@github.issues(repo).each do |issue|
|
60
|
+
__load_issue issue if issue.pull_request?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def by_date
|
65
|
+
sorted_pulls = @pulls.sort_by { |pr| pr.date }
|
66
|
+
|
67
|
+
block_given? ? sorted_pulls.each { |pr| yield pr } : sorted_pulls
|
68
|
+
end
|
69
|
+
|
70
|
+
def repos
|
71
|
+
@pulls.collect { |pr| pr.repo }.uniq
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def __load_issue(issue)
|
77
|
+
@pulls.push PullRequest.new issue
|
78
|
+
end
|
79
|
+
|
80
|
+
def __authenticate(token)
|
81
|
+
token ? Octokit::Client.new(access_token: token) : nil
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devtools-prlist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Donovan Young
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: config
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devtools-base
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.13'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.13'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.4'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.4'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: factory_girl
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.0'
|
125
|
+
description: Queries GitHub pull requests and displays a list. Can filter based on
|
126
|
+
labels
|
127
|
+
email:
|
128
|
+
- dyoung522@gmail.com
|
129
|
+
executables:
|
130
|
+
- prlist
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".codeclimate.yml"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".rubocop.yml"
|
138
|
+
- ".travis.yml"
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/setup
|
145
|
+
- devtools-prlist.gemspec
|
146
|
+
- exe/prlist
|
147
|
+
- lib/pr_list.rb
|
148
|
+
- lib/pr_list/options.rb
|
149
|
+
- lib/pr_list/pull_requests.rb
|
150
|
+
- lib/pr_list/version.rb
|
151
|
+
homepage: https://github.com/dyoung522/devtools-prlist
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.6.8
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: Queries GitHub pull requests
|
175
|
+
test_files: []
|