pronto 0.9.5 → 0.10.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 +5 -5
- data/CHANGELOG.md +21 -1
- data/LICENSE +1 -1
- data/README.md +17 -6
- data/lib/pronto/bitbucket.rb +7 -0
- data/lib/pronto/cli.rb +10 -5
- data/lib/pronto/clients/bitbucket_client.rb +13 -2
- data/lib/pronto/config.rb +1 -1
- data/lib/pronto/config_file.rb +2 -1
- data/lib/pronto/formatter/bitbucket_pull_request_formatter.rb +10 -0
- data/lib/pronto/formatter/git_formatter.rb +2 -0
- data/lib/pronto/formatter/text_message_decorator.rb +1 -0
- data/lib/pronto/git/repository.rb +7 -0
- data/lib/pronto/github.rb +12 -11
- data/lib/pronto/github_pull.rb +43 -0
- data/lib/pronto/version.rb +1 -1
- data/pronto.gemspec +8 -9
- metadata +69 -77
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c46191096dc80dd16c7d74cb071776e3d527c58030b205f13ef7cdd814bc2a75
|
|
4
|
+
data.tar.gz: c0e30815ad2b8e4cc4dc5b0e3f020347346a2e27463855951399b270b136015b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 005ccdcd8d549c490828c473658708c273f982fca0923897444cb84d02e2757b539d1acdf2accbe87220e08a55d5d2b3168780090c996e0449416cde798eaf92
|
|
7
|
+
data.tar.gz: 4b3b8aefc717056f27840f5ad1693f6d053e4988c4d892b281dadb55ac6dbbe9824dd97bccc609caab3d2e772e60802bb45c0021772ef64fb19883219bd4f62e
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
### New features
|
|
6
|
+
|
|
7
|
+
* [#301](https://github.com/prontolabs/pronto/pull/301): add ability to auto approve Bitbucket pull requests.
|
|
8
|
+
* [#331](https://github.com/prontolabs/pronto/pull/331): allow to specify PATH in "run" command.
|
|
9
|
+
|
|
10
|
+
### Bugs fixed
|
|
11
|
+
|
|
12
|
+
* [#258](https://github.com/prontolabs/pronto/pull/258): fix blame returning nil when file does not exist in the git tree.
|
|
13
|
+
* [#270](https://github.com/prontolabs/pronto/pull/270): fix ${line} in text format to mean line number.
|
|
14
|
+
* [#282](https://github.com/prontolabs/pronto/issues/282): relax rainbow dependency.
|
|
15
|
+
* [#329](https://github.com/prontolabs/pronto/pull/329): correctly handle renamed-only files.
|
|
16
|
+
|
|
17
|
+
### Changes
|
|
18
|
+
|
|
19
|
+
* Depend on thor `0.20.*`.
|
|
20
|
+
* [#298](https://github.com/prontolabs/pronto/pull/298): change default GitLab API endpoint to v4.
|
|
21
|
+
* [#332](https://github.com/prontolabs/pronto/pull/332): remove support for Ruby older than 2.3.0.
|
|
22
|
+
|
|
23
|
+
## 0.9.5
|
|
24
|
+
|
|
5
25
|
### Bugs fixed
|
|
6
26
|
|
|
7
27
|
* [#253](https://github.com/prontolabs/pronto/pull/253): fix an infinite loop when Bitbucket Server sends a paginated response.
|
|
@@ -51,7 +71,7 @@
|
|
|
51
71
|
### Changes
|
|
52
72
|
|
|
53
73
|
* [#193](https://github.com/prontolabs/pronto/issues/193): rename `pronto run --index` option to `--unstaged`.
|
|
54
|
-
* [#49](https://github.com/prontolabs/pronto/issues/49): handle
|
|
74
|
+
* [#49](https://github.com/prontolabs/pronto/issues/49): handle nonexistence of GitHub pull requests gracefully.
|
|
55
75
|
* [#217](https://github.com/prontolabs/pronto/issues/217): depend on `octokit >= 4.7.0`.
|
|
56
76
|
* [#224](https://github.com/prontolabs/pronto/issues/224): depend on `gitlab >= 4.0.0`.
|
|
57
77
|
* [#222](https://github.com/prontolabs/pronto/pull/184): prefix PULL_REQUEST_ID env variable with `PRONTO_`.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# Pronto
|
|
2
2
|
|
|
3
3
|
[](http://travis-ci.org/prontolabs/pronto)
|
|
4
|
-
[](https://codeclimate.com/github/prontolabs/pronto)
|
|
5
5
|
[](https://codeclimate.com/github/prontolabs/pronto)
|
|
6
6
|
[](http://badge.fury.io/rb/pronto)
|
|
7
|
-
[](https://gemnasium.com/prontolabs/pronto)
|
|
8
7
|
[](http://inch-ci.org/github/prontolabs/pronto)
|
|
9
8
|
|
|
10
9
|
**Pronto** runs analysis quickly by checking only the relevant changes. Created to
|
|
@@ -151,7 +150,7 @@ on GitLab commits using `GitlabFormatter`.
|
|
|
151
150
|
Set the `PRONTO_GITLAB_API_ENDPOINT` environment variable or value in `.pronto.yml` to
|
|
152
151
|
your API endpoint URL. If you are using Gitlab.com's hosted service your
|
|
153
152
|
endpoint will be set by default.
|
|
154
|
-
Set the `PRONTO_GITLAB_API_PRIVATE_TOKEN` environment variable or value in `.pronto.yml
|
|
153
|
+
Set the `PRONTO_GITLAB_API_PRIVATE_TOKEN` environment variable or value in `.pronto.yml`
|
|
155
154
|
to your Gitlab private token which you can find in your account settings.
|
|
156
155
|
|
|
157
156
|
Then just run it:
|
|
@@ -168,7 +167,6 @@ on Bitbucket commits using `BitbucketFormatter` or `BitbucketPullRequestFormatte
|
|
|
168
167
|
Add Pronto runners you want to use to your Gemfile:
|
|
169
168
|
|
|
170
169
|
Set the PRONTO_BITBUCKET_USERNAME and PRONTO_BITBUCKET_PASSWORD environment variables or values in `.pronto.yml`.
|
|
171
|
-
.
|
|
172
170
|
|
|
173
171
|
Then just run it:
|
|
174
172
|
|
|
@@ -262,20 +260,26 @@ The following values are available only to the text formatter:
|
|
|
262
260
|
Pronto can run various tools and libraries, as long as there's a runner for it.
|
|
263
261
|
Currently available:
|
|
264
262
|
|
|
263
|
+
* [pronto-blacklist](https://github.com/pbstriker38/pronto-blacklist)
|
|
265
264
|
* [pronto-brakeman](https://github.com/prontolabs/pronto-brakeman)
|
|
266
265
|
* [pronto-coffeelint](https://github.com/siebertm/pronto-coffeelint)
|
|
266
|
+
* [pronto-clang_format](https://github.com/micjabbour/pronto-clang_format)
|
|
267
|
+
* [pronto-clang_tidy](https://github.com/micjabbour/pronto-clang_tidy)
|
|
267
268
|
* [pronto-clippy](https://github.com/hauleth/pronto-clippy)
|
|
268
269
|
* [pronto-credo](https://github.com/carakan/pronto-credo)
|
|
269
270
|
* [pronto-dialyzer](https://github.com/iurifq/pronto-dialyzer)
|
|
270
271
|
* [pronto-dirty_words](https://github.com/kevinjalbert/pronto-dirty_words)
|
|
271
272
|
* [pronto-dogma](https://github.com/iurifq/pronto-dogma)
|
|
273
|
+
* [pronto-erb_lint](https://github.com/tleish/pronto-erb_lint)
|
|
272
274
|
* [pronto-eslint](https://github.com/prontolabs/pronto-eslint) (uses [eslintrb](https://github.com/zendesk/eslintrb))
|
|
273
275
|
* [pronto-eslint_npm](https://github.com/doits/pronto-eslint_npm) (uses eslint installed from npm)
|
|
274
276
|
* [pronto-fasterer](https://github.com/prontolabs/pronto-fasterer)
|
|
277
|
+
* [pronto-flake8](https://github.com/scoremedia/pronto-flake8)
|
|
275
278
|
* [pronto-flay](https://github.com/prontolabs/pronto-flay)
|
|
276
279
|
* [pronto-flow](https://github.com/kevinjalbert/pronto-flow)
|
|
277
280
|
* [pronto-foodcritic](https://github.com/prontolabs/pronto-foodcritic)
|
|
278
281
|
* [pronto-haml](https://github.com/prontolabs/pronto-haml)
|
|
282
|
+
* [pronto-inspec](https://github.com/stiller-leser/pronto-inspec)
|
|
279
283
|
* [pronto-jscs](https://github.com/spajus/pronto-jscs)
|
|
280
284
|
* [pronto-jshint](https://github.com/prontolabs/pronto-jshint)
|
|
281
285
|
* [pronto-json](https://github.com/deees/pronto-json)
|
|
@@ -283,6 +287,7 @@ Currently available:
|
|
|
283
287
|
* [pronto-perl_lint](https://github.com/bells17/pronto-perl_lint)
|
|
284
288
|
* [pronto-phpcs](https://github.com/EllisV/pronto-phpcs)
|
|
285
289
|
* [pronto-phpmd](https://github.com/EllisV/pronto-phpmd)
|
|
290
|
+
* [pronto-phpstan](https://github.com/Powerhamster/pronto-phpstan)
|
|
286
291
|
* [pronto-poper](https://github.com/prontolabs/pronto-poper)
|
|
287
292
|
* [pronto-rails_best_practices](https://github.com/prontolabs/pronto-rails_best_practices)
|
|
288
293
|
* [pronto-rails_schema](https://github.com/raimondasv/pronto-rails_schema)
|
|
@@ -298,22 +303,28 @@ Currently available:
|
|
|
298
303
|
* [pronto-tailor](https://github.com/ajanauskas/pronto-tailor)
|
|
299
304
|
* [pronto-textlint](https://github.com/seikichi/pronto-textlint)
|
|
300
305
|
* [pronto-tslint_npm](https://github.com/eprislac/pronto-tslint_npm)
|
|
306
|
+
* [pronto-yamllint](https://github.com/pauliusm/pronto-yamllint)
|
|
307
|
+
* [pronto-goodcheck](https://github.com/aergonaut/pronto-goodcheck)
|
|
308
|
+
* [pronto-undercover](https://github.com/grodowski/pronto-undercover)
|
|
301
309
|
|
|
302
310
|
## Articles
|
|
303
311
|
|
|
304
312
|
Articles to help you to get started:
|
|
305
313
|
|
|
314
|
+
* [Effortless Code Conventions Review for Pull Request Changes](https://jtway.co/effortless-code-review-for-pull-request-changes-241206b1cb04)
|
|
306
315
|
* [Automating code review with Pronto (and friends)](http://everydayrails.com/2015/02/17/pronto-ruby-code-review.html)
|
|
307
316
|
* [Setup Pronto with CircleCI](https://medium.com/@MaximAbramchuk/circleci-github-pr-commenting-ruby-scss-coffeescript-javascript-git-and-etc-fbcbe2a378a5#.gk5f14p3j)
|
|
308
317
|
* [Continuous Static Analysis using Pronto](http://codingfearlessly.com/2014/11/06/continuous-static-analysis/)
|
|
309
318
|
* [Pronto and git hooks](http://elliotthilaire.net/gem-pronto-and-git-hooks/)
|
|
310
319
|
* [How to end fruitless dev discussions about your project’s code style?](https://medium.com/appaloosa-store-engineering/how-to-end-fruitless-dev-discussions-about-your-project-s-code-style-245070bff6d4)
|
|
311
|
-
* [Free automated code reviews using Pronto](https://hovancik.net/blog/2016/04/11/free-automated-code-reviews-using-pronto
|
|
320
|
+
* [Free automated code reviews using Pronto](https://hovancik.net/blog/2016/04/11/free-automated-code-reviews-using-pronto/)
|
|
312
321
|
* [Automated Elixir code review with Github, Credo and Travis CI](https://medium.com/fazibear/automated-elixir-code-review-with-github-credo-and-travis-ci-986cd56b8f02)
|
|
313
322
|
* [Running Rubocop before git commit](https://christoph.luppri.ch/articles/2016/11/21/running-rubocop-before-git-commit/)
|
|
314
323
|
* [Pronto, Codeship and GitHub for automatic code review](http://abinoam.tl1n.com/pronto-codeship-and-github-for-automatic-code-review/)
|
|
315
324
|
* [How to automatically review your PRs for style violations with Pronto and RuboCop](https://christoph.luppri.ch/articles/2017/03/05/how-to-automatically-review-your-prs-for-style-violations-with-pronto-and-rubocop/)
|
|
316
325
|
* [Create your own Pronto Runner](https://kevinjalbert.com/create-your-own-pronto-runner/)
|
|
326
|
+
* [Make Code Reviews A Little Bit Better With Automation](https://medium.com/jimmy-farrell/make-codes-reviews-a-little-bit-better-with-automation-35640df08a62)
|
|
327
|
+
* [Stop shipping untested Ruby code with undercover](https://medium.com/futuredev/stop-shipping-untested-ruby-code-with-undercover-1edc963be4a6)
|
|
317
328
|
|
|
318
329
|
Make a Pull Request to add something you wrote or found useful.
|
|
319
330
|
|
|
@@ -323,4 +334,4 @@ Make a Pull Request to add something you wrote or found useful.
|
|
|
323
334
|
|
|
324
335
|
## Copyright
|
|
325
336
|
|
|
326
|
-
Copyright (c) 2013-
|
|
337
|
+
Copyright (c) 2013-2018 Mindaugas Mozūras. See [LICENSE](LICENSE) for further details.
|
data/lib/pronto/bitbucket.rb
CHANGED
data/lib/pronto/cli.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Pronto
|
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
desc 'run', 'Run Pronto'
|
|
15
|
+
desc 'run [PATH]', 'Run Pronto'
|
|
16
16
|
|
|
17
17
|
method_option :'exit-code',
|
|
18
18
|
type: :boolean,
|
|
@@ -45,7 +45,9 @@ module Pronto
|
|
|
45
45
|
aliases: ['formatter', '-f'],
|
|
46
46
|
desc: "Pick output formatters. Available: #{::Pronto::Formatter.names.join(', ')}"
|
|
47
47
|
|
|
48
|
-
def run(path =
|
|
48
|
+
def run(path = '.')
|
|
49
|
+
path = File.expand_path(path)
|
|
50
|
+
|
|
49
51
|
gem_names = options[:runner].any? ? options[:runner] : ::Pronto::GemNames.new.to_a
|
|
50
52
|
gem_names.each do |gem_name|
|
|
51
53
|
require "pronto/#{gem_name}"
|
|
@@ -56,16 +58,19 @@ module Pronto
|
|
|
56
58
|
commit_options = %i[staged unstaged index]
|
|
57
59
|
commit = commit_options.find { |o| options[o] } || options[:commit]
|
|
58
60
|
|
|
59
|
-
repo_workdir = ::Rugged::Repository.discover(
|
|
61
|
+
repo_workdir = ::Rugged::Repository.discover(path).workdir
|
|
62
|
+
relative = path.sub(repo_workdir, '')
|
|
63
|
+
|
|
60
64
|
messages = Dir.chdir(repo_workdir) do
|
|
61
|
-
|
|
65
|
+
file = relative.length != path.length ? relative : nil
|
|
66
|
+
::Pronto.run(commit, '.', formatters, file)
|
|
62
67
|
end
|
|
63
68
|
if options[:'exit-code']
|
|
64
69
|
error_messages_count = messages.count { |m| m.level != :info }
|
|
65
70
|
exit(error_messages_count)
|
|
66
71
|
end
|
|
67
72
|
rescue Rugged::RepositoryError
|
|
68
|
-
puts '"pronto"
|
|
73
|
+
puts '"pronto" must be run from within a git repository or must be supplied the path to a git repository'
|
|
69
74
|
rescue Pronto::Error => e
|
|
70
75
|
$stderr.puts "Pronto errored: #{e.message}"
|
|
71
76
|
end
|
|
@@ -21,8 +21,7 @@ class BitbucketClient
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def pull_requests(slug)
|
|
24
|
-
|
|
25
|
-
response = get("#{base}/#{slug}/pullrequests?state=OPEN")
|
|
24
|
+
response = get("#{pull_request_api(slug)}/pullrequests?state=OPEN")
|
|
26
25
|
openstruct(response['values'])
|
|
27
26
|
end
|
|
28
27
|
|
|
@@ -30,8 +29,20 @@ class BitbucketClient
|
|
|
30
29
|
post("/#{slug}/pullrequests/#{pull_id}/comments", body, path, position)
|
|
31
30
|
end
|
|
32
31
|
|
|
32
|
+
def approve_pull_request(slug, pull_id)
|
|
33
|
+
self.class.post("#{pull_request_api(slug)}/pullrequests/#{pull_id}/approve")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def unapprove_pull_request(slug, pull_id)
|
|
37
|
+
self.class.delete("#{pull_request_api(slug)}/pullrequests/#{pull_id}/approve")
|
|
38
|
+
end
|
|
39
|
+
|
|
33
40
|
private
|
|
34
41
|
|
|
42
|
+
def pull_request_api(slug)
|
|
43
|
+
"https://api.bitbucket.org/2.0/repositories/#{slug}"
|
|
44
|
+
end
|
|
45
|
+
|
|
35
46
|
def openstruct(response)
|
|
36
47
|
response.map { |r| OpenStruct.new(r) }
|
|
37
48
|
end
|
data/lib/pronto/config.rb
CHANGED
data/lib/pronto/config_file.rb
CHANGED
|
@@ -16,13 +16,14 @@ module Pronto
|
|
|
16
16
|
'gitlab' => {
|
|
17
17
|
'slug' => nil,
|
|
18
18
|
'api_private_token' => nil,
|
|
19
|
-
'api_endpoint' => 'https://gitlab.com/api/
|
|
19
|
+
'api_endpoint' => 'https://gitlab.com/api/v4'
|
|
20
20
|
},
|
|
21
21
|
'bitbucket' => {
|
|
22
22
|
'slug' => nil,
|
|
23
23
|
'username' => nil,
|
|
24
24
|
'password' => nil,
|
|
25
25
|
'api_endpoint' => nil,
|
|
26
|
+
'auto_approve' => false,
|
|
26
27
|
'web_endpoint' => 'https://bitbucket.org/'
|
|
27
28
|
},
|
|
28
29
|
'text' => {
|
|
@@ -12,6 +12,16 @@ module Pronto
|
|
|
12
12
|
def line_number(message, _)
|
|
13
13
|
message.line.line.new_lineno if message.line
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
def approve_pull_request(comments_count, additions_count, client)
|
|
17
|
+
return if config.bitbucket_auto_approve == false
|
|
18
|
+
|
|
19
|
+
if comments_count > 0 && additions_count > 0
|
|
20
|
+
client.unapprove_pull_request
|
|
21
|
+
elsif comments_count == 0
|
|
22
|
+
client.approve_pull_request
|
|
23
|
+
end
|
|
24
|
+
end
|
|
15
25
|
end
|
|
16
26
|
end
|
|
17
27
|
end
|
|
@@ -7,6 +7,8 @@ module Pronto
|
|
|
7
7
|
comments = new_comments(messages, patches)
|
|
8
8
|
additions = remove_duplicate_comments(existing, comments)
|
|
9
9
|
submit_comments(client, additions)
|
|
10
|
+
|
|
11
|
+
approve_pull_request(comments.count, additions.count, client) if defined?(self.approve_pull_request)
|
|
10
12
|
|
|
11
13
|
"#{additions.count} Pronto messages posted to #{pretty_name}"
|
|
12
14
|
end
|
|
@@ -19,6 +19,7 @@ module Pronto
|
|
|
19
19
|
[merge_base, patches]
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
patches.find_similar!(renames: true)
|
|
22
23
|
Patches.new(self, target, patches)
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -49,6 +50,8 @@ module Pronto
|
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
def blame(path, lineno)
|
|
53
|
+
return if new_file?(path)
|
|
54
|
+
|
|
52
55
|
Rugged::Blame.new(@repo, path, min_line: lineno, max_line: lineno,
|
|
53
56
|
track_copies_same_file: true,
|
|
54
57
|
track_copies_any_commit_copies: true)[0]
|
|
@@ -72,6 +75,10 @@ module Pronto
|
|
|
72
75
|
|
|
73
76
|
private
|
|
74
77
|
|
|
78
|
+
def new_file?(path)
|
|
79
|
+
@repo.status(path).include?(:index_new)
|
|
80
|
+
end
|
|
81
|
+
|
|
75
82
|
def empty_patches(sha)
|
|
76
83
|
Patches.new(self, sha, [])
|
|
77
84
|
end
|
data/lib/pronto/github.rb
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
require 'pronto/github_pull'
|
|
2
|
+
|
|
1
3
|
module Pronto
|
|
2
4
|
class Github < Client
|
|
5
|
+
def initialize(repo)
|
|
6
|
+
super(repo)
|
|
7
|
+
@github_pull = Pronto::GithubPull.new(client, slug)
|
|
8
|
+
end
|
|
9
|
+
|
|
3
10
|
def pull_comments(sha)
|
|
4
11
|
@comment_cache["#{pull_id}/#{sha}"] ||= begin
|
|
5
12
|
client.pull_comments(slug, pull_id).map do |comment|
|
|
@@ -43,7 +50,7 @@ module Pronto
|
|
|
43
50
|
|
|
44
51
|
options = {
|
|
45
52
|
event: 'COMMENT',
|
|
46
|
-
accept: 'application/vnd.github.
|
|
53
|
+
accept: 'application/vnd.github.v3.diff+json', # https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review
|
|
47
54
|
comments: comments.map do |c|
|
|
48
55
|
{ path: c.path, position: c.position, body: c.body }
|
|
49
56
|
end
|
|
@@ -80,7 +87,7 @@ module Pronto
|
|
|
80
87
|
end
|
|
81
88
|
|
|
82
89
|
def pull_id
|
|
83
|
-
|
|
90
|
+
env_pull_id || pull[:number].to_i
|
|
84
91
|
end
|
|
85
92
|
|
|
86
93
|
def pull_sha
|
|
@@ -89,18 +96,12 @@ module Pronto
|
|
|
89
96
|
|
|
90
97
|
def pull
|
|
91
98
|
@pull ||= if env_pull_id
|
|
92
|
-
|
|
99
|
+
@github_pull.pull_by_id(env_pull_id)
|
|
93
100
|
elsif @repo.branch
|
|
94
|
-
|
|
101
|
+
@github_pull.pull_by_branch(@repo.branch)
|
|
95
102
|
elsif @repo.head_detached?
|
|
96
|
-
|
|
97
|
-
pr[:head][:sha] == @repo.head_commit_sha
|
|
98
|
-
end
|
|
103
|
+
@github_pull.pull_by_commit(@repo.head_commit_sha)
|
|
99
104
|
end
|
|
100
105
|
end
|
|
101
|
-
|
|
102
|
-
def pull_requests
|
|
103
|
-
@pull_requests ||= client.pull_requests(slug)
|
|
104
|
-
end
|
|
105
106
|
end
|
|
106
107
|
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Pronto
|
|
2
|
+
# Provides strategies for finding corresponding PR on GitHub
|
|
3
|
+
class GithubPull
|
|
4
|
+
def initialize(client, slug)
|
|
5
|
+
@client = client
|
|
6
|
+
@slug = slug
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def pull_requests
|
|
10
|
+
@pull_requests ||= @client.pull_requests(@slug)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def pull_by_id(pull_id)
|
|
14
|
+
result = pull_requests.find { |pr| pr[:number].to_i == pull_id }
|
|
15
|
+
unless result
|
|
16
|
+
message = "Pull request ##{pull_id} was not found in #{@slug}."
|
|
17
|
+
raise Pronto::Error, message
|
|
18
|
+
end
|
|
19
|
+
result
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def pull_by_branch(branch)
|
|
23
|
+
result = pull_requests.find { |pr| pr[:head][:ref] == branch }
|
|
24
|
+
unless result
|
|
25
|
+
raise Pronto::Error, "Pull request for branch #{branch} " \
|
|
26
|
+
"was not found in #{@slug}."
|
|
27
|
+
end
|
|
28
|
+
result
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def pull_by_commit(sha)
|
|
32
|
+
result = pull_requests.find do |pr|
|
|
33
|
+
pr[:head][:sha] == sha
|
|
34
|
+
end
|
|
35
|
+
unless result
|
|
36
|
+
message = "Pull request with head #{sha} " \
|
|
37
|
+
"was not found in #{@slug}."
|
|
38
|
+
raise Pronto::Error, message
|
|
39
|
+
end
|
|
40
|
+
result
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/pronto/version.rb
CHANGED
data/pronto.gemspec
CHANGED
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
|
20
20
|
EOF
|
|
21
21
|
|
|
22
22
|
s.licenses = ['MIT']
|
|
23
|
-
s.required_ruby_version = '>= 2.
|
|
23
|
+
s.required_ruby_version = '>= 2.3.0'
|
|
24
24
|
s.rubygems_version = '1.8.23'
|
|
25
25
|
|
|
26
26
|
s.files = `git ls-files`.split($RS).reject do |file|
|
|
@@ -40,19 +40,18 @@ Gem::Specification.new do |s|
|
|
|
40
40
|
s.require_paths = ['lib']
|
|
41
41
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
42
42
|
|
|
43
|
-
s.add_runtime_dependency('rugged', '~> 0.24', '>= 0.23.0')
|
|
44
|
-
s.add_runtime_dependency('thor', '~> 0.19.0')
|
|
45
|
-
s.add_runtime_dependency('octokit', '~> 4.7', '>= 4.7.0')
|
|
46
43
|
s.add_runtime_dependency('gitlab', '~> 4.0', '>= 4.0.0')
|
|
47
44
|
s.add_runtime_dependency('httparty', '>= 0.13.7')
|
|
48
|
-
s.add_runtime_dependency('
|
|
45
|
+
s.add_runtime_dependency('octokit', '~> 4.7', '>= 4.7.0')
|
|
46
|
+
s.add_runtime_dependency('rainbow', '>= 2.2', '< 4.0')
|
|
47
|
+
s.add_runtime_dependency('rugged', '~> 0.24', '>= 0.23.0')
|
|
48
|
+
s.add_runtime_dependency('thor', '~> 0.20.0')
|
|
49
|
+
s.add_development_dependency('bundler', '>= 1.15')
|
|
50
|
+
s.add_development_dependency('pronto-rubocop', '~> 0.9.0')
|
|
49
51
|
s.add_development_dependency('rake', '~> 12.0')
|
|
50
52
|
s.add_development_dependency('rspec', '~> 3.4')
|
|
51
53
|
s.add_development_dependency('rspec-its', '~> 1.2')
|
|
52
54
|
s.add_development_dependency('rspec-expectations', '~> 3.4')
|
|
53
|
-
s.add_development_dependency('
|
|
55
|
+
s.add_development_dependency('rubocop', '~> 0.58')
|
|
54
56
|
s.add_development_dependency('simplecov', '~> 0.14')
|
|
55
|
-
s.add_development_dependency('rubocop', '~> 0.47')
|
|
56
|
-
s.add_development_dependency('pronto-rubocop', '~> 0.9.0')
|
|
57
|
-
s.add_development_dependency('codeclimate-test-reporter', '~> 1.0')
|
|
58
57
|
end
|
metadata
CHANGED
|
@@ -1,161 +1,167 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pronto
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mindaugas Mozūras
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
14
|
+
name: gitlab
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0.24'
|
|
20
17
|
- - ">="
|
|
21
18
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.
|
|
19
|
+
version: 4.0.0
|
|
20
|
+
- - "~>"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '4.0'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
|
-
- - "~>"
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
version: '0.24'
|
|
30
27
|
- - ">="
|
|
31
28
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
29
|
+
version: 4.0.0
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '4.0'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
34
|
+
name: httparty
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
|
-
- - "
|
|
37
|
+
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.13.7
|
|
40
40
|
type: :runtime
|
|
41
41
|
prerelease: false
|
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
|
-
- - "
|
|
44
|
+
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.
|
|
46
|
+
version: 0.13.7
|
|
47
47
|
- !ruby/object:Gem::Dependency
|
|
48
48
|
name: octokit
|
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '4.7'
|
|
54
51
|
- - ">="
|
|
55
52
|
- !ruby/object:Gem::Version
|
|
56
53
|
version: 4.7.0
|
|
54
|
+
- - "~>"
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '4.7'
|
|
57
57
|
type: :runtime
|
|
58
58
|
prerelease: false
|
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
|
60
60
|
requirements:
|
|
61
|
-
- - "~>"
|
|
62
|
-
- !ruby/object:Gem::Version
|
|
63
|
-
version: '4.7'
|
|
64
61
|
- - ">="
|
|
65
62
|
- !ruby/object:Gem::Version
|
|
66
63
|
version: 4.7.0
|
|
64
|
+
- - "~>"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '4.7'
|
|
67
67
|
- !ruby/object:Gem::Dependency
|
|
68
|
-
name:
|
|
68
|
+
name: rainbow
|
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
|
-
- - "~>"
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
version: '4.0'
|
|
74
71
|
- - ">="
|
|
75
72
|
- !ruby/object:Gem::Version
|
|
76
|
-
version:
|
|
73
|
+
version: '2.2'
|
|
74
|
+
- - "<"
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '4.0'
|
|
77
77
|
type: :runtime
|
|
78
78
|
prerelease: false
|
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
|
80
80
|
requirements:
|
|
81
|
-
- - "~>"
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: '4.0'
|
|
84
81
|
- - ">="
|
|
85
82
|
- !ruby/object:Gem::Version
|
|
86
|
-
version:
|
|
83
|
+
version: '2.2'
|
|
84
|
+
- - "<"
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: '4.0'
|
|
87
87
|
- !ruby/object:Gem::Dependency
|
|
88
|
-
name:
|
|
88
|
+
name: rugged
|
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
|
90
90
|
requirements:
|
|
91
91
|
- - ">="
|
|
92
92
|
- !ruby/object:Gem::Version
|
|
93
|
-
version: 0.
|
|
93
|
+
version: 0.23.0
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0.24'
|
|
94
97
|
type: :runtime
|
|
95
98
|
prerelease: false
|
|
96
99
|
version_requirements: !ruby/object:Gem::Requirement
|
|
97
100
|
requirements:
|
|
98
101
|
- - ">="
|
|
99
102
|
- !ruby/object:Gem::Version
|
|
100
|
-
version: 0.
|
|
103
|
+
version: 0.23.0
|
|
104
|
+
- - "~>"
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: '0.24'
|
|
101
107
|
- !ruby/object:Gem::Dependency
|
|
102
|
-
name:
|
|
108
|
+
name: thor
|
|
103
109
|
requirement: !ruby/object:Gem::Requirement
|
|
104
110
|
requirements:
|
|
105
111
|
- - "~>"
|
|
106
112
|
- !ruby/object:Gem::Version
|
|
107
|
-
version:
|
|
113
|
+
version: 0.20.0
|
|
108
114
|
type: :runtime
|
|
109
115
|
prerelease: false
|
|
110
116
|
version_requirements: !ruby/object:Gem::Requirement
|
|
111
117
|
requirements:
|
|
112
118
|
- - "~>"
|
|
113
119
|
- !ruby/object:Gem::Version
|
|
114
|
-
version:
|
|
120
|
+
version: 0.20.0
|
|
115
121
|
- !ruby/object:Gem::Dependency
|
|
116
|
-
name:
|
|
122
|
+
name: bundler
|
|
117
123
|
requirement: !ruby/object:Gem::Requirement
|
|
118
124
|
requirements:
|
|
119
|
-
- - "
|
|
125
|
+
- - ">="
|
|
120
126
|
- !ruby/object:Gem::Version
|
|
121
|
-
version: '
|
|
127
|
+
version: '1.15'
|
|
122
128
|
type: :development
|
|
123
129
|
prerelease: false
|
|
124
130
|
version_requirements: !ruby/object:Gem::Requirement
|
|
125
131
|
requirements:
|
|
126
|
-
- - "
|
|
132
|
+
- - ">="
|
|
127
133
|
- !ruby/object:Gem::Version
|
|
128
|
-
version: '
|
|
134
|
+
version: '1.15'
|
|
129
135
|
- !ruby/object:Gem::Dependency
|
|
130
|
-
name:
|
|
136
|
+
name: pronto-rubocop
|
|
131
137
|
requirement: !ruby/object:Gem::Requirement
|
|
132
138
|
requirements:
|
|
133
139
|
- - "~>"
|
|
134
140
|
- !ruby/object:Gem::Version
|
|
135
|
-
version:
|
|
141
|
+
version: 0.9.0
|
|
136
142
|
type: :development
|
|
137
143
|
prerelease: false
|
|
138
144
|
version_requirements: !ruby/object:Gem::Requirement
|
|
139
145
|
requirements:
|
|
140
146
|
- - "~>"
|
|
141
147
|
- !ruby/object:Gem::Version
|
|
142
|
-
version:
|
|
148
|
+
version: 0.9.0
|
|
143
149
|
- !ruby/object:Gem::Dependency
|
|
144
|
-
name:
|
|
150
|
+
name: rake
|
|
145
151
|
requirement: !ruby/object:Gem::Requirement
|
|
146
152
|
requirements:
|
|
147
153
|
- - "~>"
|
|
148
154
|
- !ruby/object:Gem::Version
|
|
149
|
-
version: '
|
|
155
|
+
version: '12.0'
|
|
150
156
|
type: :development
|
|
151
157
|
prerelease: false
|
|
152
158
|
version_requirements: !ruby/object:Gem::Requirement
|
|
153
159
|
requirements:
|
|
154
160
|
- - "~>"
|
|
155
161
|
- !ruby/object:Gem::Version
|
|
156
|
-
version: '
|
|
162
|
+
version: '12.0'
|
|
157
163
|
- !ruby/object:Gem::Dependency
|
|
158
|
-
name: rspec
|
|
164
|
+
name: rspec
|
|
159
165
|
requirement: !ruby/object:Gem::Requirement
|
|
160
166
|
requirements:
|
|
161
167
|
- - "~>"
|
|
@@ -169,75 +175,61 @@ dependencies:
|
|
|
169
175
|
- !ruby/object:Gem::Version
|
|
170
176
|
version: '3.4'
|
|
171
177
|
- !ruby/object:Gem::Dependency
|
|
172
|
-
name:
|
|
178
|
+
name: rspec-its
|
|
173
179
|
requirement: !ruby/object:Gem::Requirement
|
|
174
180
|
requirements:
|
|
175
181
|
- - "~>"
|
|
176
182
|
- !ruby/object:Gem::Version
|
|
177
|
-
version: '1.
|
|
183
|
+
version: '1.2'
|
|
178
184
|
type: :development
|
|
179
185
|
prerelease: false
|
|
180
186
|
version_requirements: !ruby/object:Gem::Requirement
|
|
181
187
|
requirements:
|
|
182
188
|
- - "~>"
|
|
183
189
|
- !ruby/object:Gem::Version
|
|
184
|
-
version: '1.
|
|
190
|
+
version: '1.2'
|
|
185
191
|
- !ruby/object:Gem::Dependency
|
|
186
|
-
name:
|
|
192
|
+
name: rspec-expectations
|
|
187
193
|
requirement: !ruby/object:Gem::Requirement
|
|
188
194
|
requirements:
|
|
189
195
|
- - "~>"
|
|
190
196
|
- !ruby/object:Gem::Version
|
|
191
|
-
version: '
|
|
197
|
+
version: '3.4'
|
|
192
198
|
type: :development
|
|
193
199
|
prerelease: false
|
|
194
200
|
version_requirements: !ruby/object:Gem::Requirement
|
|
195
201
|
requirements:
|
|
196
202
|
- - "~>"
|
|
197
203
|
- !ruby/object:Gem::Version
|
|
198
|
-
version: '
|
|
204
|
+
version: '3.4'
|
|
199
205
|
- !ruby/object:Gem::Dependency
|
|
200
206
|
name: rubocop
|
|
201
207
|
requirement: !ruby/object:Gem::Requirement
|
|
202
208
|
requirements:
|
|
203
209
|
- - "~>"
|
|
204
210
|
- !ruby/object:Gem::Version
|
|
205
|
-
version: '0.
|
|
206
|
-
type: :development
|
|
207
|
-
prerelease: false
|
|
208
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
209
|
-
requirements:
|
|
210
|
-
- - "~>"
|
|
211
|
-
- !ruby/object:Gem::Version
|
|
212
|
-
version: '0.47'
|
|
213
|
-
- !ruby/object:Gem::Dependency
|
|
214
|
-
name: pronto-rubocop
|
|
215
|
-
requirement: !ruby/object:Gem::Requirement
|
|
216
|
-
requirements:
|
|
217
|
-
- - "~>"
|
|
218
|
-
- !ruby/object:Gem::Version
|
|
219
|
-
version: 0.9.0
|
|
211
|
+
version: '0.58'
|
|
220
212
|
type: :development
|
|
221
213
|
prerelease: false
|
|
222
214
|
version_requirements: !ruby/object:Gem::Requirement
|
|
223
215
|
requirements:
|
|
224
216
|
- - "~>"
|
|
225
217
|
- !ruby/object:Gem::Version
|
|
226
|
-
version: 0.
|
|
218
|
+
version: '0.58'
|
|
227
219
|
- !ruby/object:Gem::Dependency
|
|
228
|
-
name:
|
|
220
|
+
name: simplecov
|
|
229
221
|
requirement: !ruby/object:Gem::Requirement
|
|
230
222
|
requirements:
|
|
231
223
|
- - "~>"
|
|
232
224
|
- !ruby/object:Gem::Version
|
|
233
|
-
version: '
|
|
225
|
+
version: '0.14'
|
|
234
226
|
type: :development
|
|
235
227
|
prerelease: false
|
|
236
228
|
version_requirements: !ruby/object:Gem::Requirement
|
|
237
229
|
requirements:
|
|
238
230
|
- - "~>"
|
|
239
231
|
- !ruby/object:Gem::Version
|
|
240
|
-
version: '
|
|
232
|
+
version: '0.14'
|
|
241
233
|
description: |2
|
|
242
234
|
Pronto runs analysis quickly by checking only the relevant changes. Created
|
|
243
235
|
to be used on pull requests, but suited for other scenarios as well. Perfect
|
|
@@ -294,6 +286,7 @@ files:
|
|
|
294
286
|
- lib/pronto/git/patches.rb
|
|
295
287
|
- lib/pronto/git/repository.rb
|
|
296
288
|
- lib/pronto/github.rb
|
|
289
|
+
- lib/pronto/github_pull.rb
|
|
297
290
|
- lib/pronto/gitlab.rb
|
|
298
291
|
- lib/pronto/logger.rb
|
|
299
292
|
- lib/pronto/message.rb
|
|
@@ -316,15 +309,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
316
309
|
requirements:
|
|
317
310
|
- - ">="
|
|
318
311
|
- !ruby/object:Gem::Version
|
|
319
|
-
version: 2.
|
|
312
|
+
version: 2.3.0
|
|
320
313
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
321
314
|
requirements:
|
|
322
315
|
- - ">="
|
|
323
316
|
- !ruby/object:Gem::Version
|
|
324
317
|
version: '0'
|
|
325
318
|
requirements: []
|
|
326
|
-
|
|
327
|
-
rubygems_version: 2.6.11
|
|
319
|
+
rubygems_version: 3.0.1
|
|
328
320
|
signing_key:
|
|
329
321
|
specification_version: 4
|
|
330
322
|
summary: Pronto runs analysis by checking only the introduced changes
|