pronto 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -6
- data/lib/pronto/cli.rb +4 -15
- data/lib/pronto/formatter/github_formatter.rb +30 -11
- data/lib/pronto/rake_task/travis_pull_request.rb +61 -0
- data/lib/pronto/version.rb +1 -1
- data/lib/rugged/diff/line.rb +14 -0
- data/lib/rugged/diff/patch.rb +0 -2
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 800c72660ff1c44c50bcb121d16addbdd3155035
|
4
|
+
data.tar.gz: 1e69d5e353aa63b326b21845f31d00d3d2a6e6dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6da3eb9370bd8b8f6a65a07fcfdd5ef8d6a2d2ff655ee8d5ae541cbc5a8036412c46b92130c2a8bcc60517332b3a6998db56a9c9a3e1d8a751c59c5ce26461c0
|
7
|
+
data.tar.gz: b0c0b6cb81e088dc11bd4d97fe06440345c32b924f66d02a208af5ef6f46ade2cbb52dbbce19e275feb0ba2bad9d069cf06d44eb715cd02e4c9291097dd7300d
|
data/README.md
CHANGED
@@ -4,14 +4,48 @@
|
|
4
4
|
[![Build Status](https://secure.travis-ci.org/mmozuras/pronto.png)](http://travis-ci.org/mmozuras/pronto)
|
5
5
|
[![Dependency Status](https://gemnasium.com/mmozuras/pronto.png)](https://gemnasium.com/mmozuras/pronto)
|
6
6
|
|
7
|
-
|
8
7
|
## Usage
|
9
8
|
|
10
|
-
|
11
|
-
|
9
|
+
Pronto runs analysis quickly by checking only the introduced changes.
|
10
|
+
|
11
|
+
### Pull Requests
|
12
|
+
|
13
|
+
You can run Pronto as part of your builds and then get results as commit
|
14
|
+
comments using `GithubFormatter`.
|
15
|
+
|
16
|
+
Actually, Pronto runs Pronto whenever you make a pull request on Pronto. It
|
17
|
+
uses Travis CI and the included `TravisPullRequest` rake task for that.
|
18
|
+
|
19
|
+
To do the same, start by adding Pronto runners you want to use to your Gemfile:
|
20
|
+
```ruby
|
21
|
+
gem 'pronto-rubocop'
|
22
|
+
```
|
23
|
+
or gemspec file:
|
24
|
+
```ruby
|
25
|
+
s.add_development_dependency 'pronto-rubocop'
|
26
|
+
```
|
27
|
+
Then run it using the included rake task or manually.
|
28
|
+
|
29
|
+
### Local Changes
|
30
|
+
|
31
|
+
You can run Pronto locally. First, install Pronto and runners you want to use:
|
32
|
+
```bash
|
33
|
+
gem install pronto
|
34
|
+
gem install pronto-rubocop
|
35
|
+
```
|
36
|
+
Then navigate to repository you want run Pronto on, and:
|
37
|
+
```bash
|
38
|
+
git checkout feature/branch
|
39
|
+
pronto exec # Pronto runs against master by default
|
40
|
+
```
|
41
|
+
|
42
|
+
Run `pronto` in your terminal without any arguments to see what more Pronto is
|
43
|
+
capable off.
|
12
44
|
|
13
|
-
##
|
45
|
+
## Runners
|
14
46
|
|
15
|
-
|
47
|
+
Pronto can run various tools and libraries, as long as there's a runner for it.
|
48
|
+
Currently available runners:
|
16
49
|
|
17
|
-
|
50
|
+
* [pronto-rubocop](https://github.com/mmozuras/pronto-rubocop)
|
51
|
+
* [pronto-flay](https://github.com/mmozuras/pronto-flay)
|
data/lib/pronto/cli.rb
CHANGED
@@ -23,28 +23,17 @@ module Pronto
|
|
23
23
|
type: :string,
|
24
24
|
default: nil,
|
25
25
|
aliases: '-f',
|
26
|
-
banner: "Formatter, defaults to text.
|
27
|
-
|
28
|
-
method_option :access_token,
|
29
|
-
type: :string,
|
30
|
-
default: nil,
|
31
|
-
aliases: '-t',
|
32
|
-
banner: 'Github access token, used for github formatter'
|
26
|
+
banner: "Formatter, defaults to text.
|
27
|
+
Available: #{::Pronto::Formatter.names.join(', ')}"
|
33
28
|
|
34
29
|
def exec
|
35
|
-
gem_names = options[:runner].any? ? options[:runner]
|
36
|
-
: ::Pronto.gem_names
|
30
|
+
gem_names = options[:runner].any? ? options[:runner] : ::Pronto.gem_names
|
37
31
|
gem_names.each do |gem_name|
|
38
32
|
require "pronto/#{gem_name}"
|
39
33
|
end
|
40
34
|
|
41
35
|
formatter = ::Pronto::Formatter.get(options[:formatter])
|
42
|
-
|
43
|
-
access_token = options[:access_token]
|
44
|
-
formatter.client = Octokit::Client.new(access_token: access_token)
|
45
|
-
end
|
46
|
-
|
47
|
-
puts ::Pronto.run(options[:commit], '.', formatter)
|
36
|
+
::Pronto.run(options[:commit], '.', formatter)
|
48
37
|
rescue Rugged::RepositoryError
|
49
38
|
puts '"pronto" should be run from a git repository'
|
50
39
|
end
|
@@ -3,31 +3,50 @@ require 'octokit'
|
|
3
3
|
module Pronto
|
4
4
|
module Formatter
|
5
5
|
class GithubFormatter
|
6
|
-
attr_writer :client
|
7
|
-
|
8
6
|
def format(messages)
|
9
7
|
messages.each do |message|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
8
|
+
repo = github_slug(message)
|
9
|
+
sha = commit_sha(message)
|
10
|
+
position = message.line.position
|
11
|
+
path = message.path
|
12
|
+
body = message.msg
|
16
13
|
|
17
|
-
|
14
|
+
create_commit_comment(repo, sha, position, path, body)
|
15
|
+
end
|
18
16
|
end
|
19
17
|
|
20
18
|
private
|
21
19
|
|
20
|
+
def create_commit_comment(repo, sha, position, path, body)
|
21
|
+
commit_comments = client.commit_comments(repo, sha)
|
22
|
+
existing_comment = commit_comments.find do |comment|
|
23
|
+
comment.position = position &&
|
24
|
+
comment.path == path &&
|
25
|
+
comment.body == body
|
26
|
+
end
|
27
|
+
|
28
|
+
if existing_comment.nil?
|
29
|
+
client.create_commit_comment(repo, sha, body, path, nil, position)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def access_token
|
34
|
+
ENV['GITHUB_ACCESS_TOKEN']
|
35
|
+
end
|
36
|
+
|
37
|
+
def client
|
38
|
+
@client ||= Octokit::Client.new(access_token: access_token)
|
39
|
+
end
|
40
|
+
|
22
41
|
def github_slug(message)
|
23
42
|
message.repo.remotes.map(&:github_slug).compact.first
|
24
43
|
end
|
25
44
|
|
26
|
-
def
|
45
|
+
def commit_sha(message)
|
27
46
|
blamelines = blame(message).lines
|
28
47
|
lineno = message.line.new_lineno
|
29
48
|
|
30
|
-
blameline = blamelines.
|
49
|
+
blameline = blamelines.find { |line| line.lineno == lineno }
|
31
50
|
|
32
51
|
blameline.commit.id if blameline
|
33
52
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'pronto'
|
2
|
+
require 'octokit'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/tasklib'
|
5
|
+
|
6
|
+
module Pronto
|
7
|
+
module RakeTask
|
8
|
+
# Provides a custom rake task to use with Travis.
|
9
|
+
#
|
10
|
+
# require 'rubocop/rake/travis_pull_request'
|
11
|
+
# Pronto::Rake::TravisPullRequest.new
|
12
|
+
class TravisPullRequest < Rake::TaskLib
|
13
|
+
attr_accessor :name
|
14
|
+
attr_accessor :verbose
|
15
|
+
|
16
|
+
def initialize(*args, &task_block)
|
17
|
+
setup_ivars(args)
|
18
|
+
|
19
|
+
unless ::Rake.application.last_comment
|
20
|
+
desc 'Run Pronto on Travis Pull Request'
|
21
|
+
end
|
22
|
+
|
23
|
+
task(name, *args) do |_, task_args|
|
24
|
+
RakeFileUtils.send(:verbose, verbose) do
|
25
|
+
if task_block
|
26
|
+
task_block.call(*[self, task_args].slice(0, task_block.arity))
|
27
|
+
end
|
28
|
+
run_task(verbose)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_task(verbose)
|
34
|
+
return if pull_request_number.nil? || pull_request_number == 'false'
|
35
|
+
|
36
|
+
client = Octokit::Client.new
|
37
|
+
|
38
|
+
pull_request = client.pull_request(repo_slug, pull_request_number)
|
39
|
+
formatter = ::Pronto::Formatter::GithubFormatter.new
|
40
|
+
|
41
|
+
::Pronto.gem_names.each { |gem_name| require "pronto/#{gem_name}" }
|
42
|
+
::Pronto.run(pull_request.base.sha, '.', formatter)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def pull_request_number
|
48
|
+
ENV['TRAVIS_PULL_REQUEST']
|
49
|
+
end
|
50
|
+
|
51
|
+
def repo_slug
|
52
|
+
ENV['TRAVIS_REPO_SLUG']
|
53
|
+
end
|
54
|
+
|
55
|
+
def setup_ivars(args)
|
56
|
+
@name = args.shift || :pronto_travis_pull_request
|
57
|
+
@verbose = true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/pronto/version.rb
CHANGED
data/lib/rugged/diff/line.rb
CHANGED
@@ -4,6 +4,20 @@ module Rugged
|
|
4
4
|
def patch
|
5
5
|
hunk.owner
|
6
6
|
end
|
7
|
+
|
8
|
+
def position
|
9
|
+
hunk_index = patch.hunks.find_index { |h| h.header == hunk.header }
|
10
|
+
line_index = patch.lines.find_index(self)
|
11
|
+
|
12
|
+
line_index + hunk_index + 1
|
13
|
+
end
|
14
|
+
|
15
|
+
def ==(other)
|
16
|
+
content == other.content &&
|
17
|
+
line_origin == other.line_origin &&
|
18
|
+
old_lineno == other.old_lineno &&
|
19
|
+
new_lineno == other.new_lineno
|
20
|
+
end
|
7
21
|
end
|
8
22
|
end
|
9
23
|
end
|
data/lib/rugged/diff/patch.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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: 2013-09-
|
11
|
+
date: 2013-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.2.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: grit
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,7 +94,21 @@ dependencies:
|
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.14.0
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pronto-rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.1.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.0
|
111
|
+
description:
|
98
112
|
email: mindaugas.mozuras@gmail.com
|
99
113
|
executables:
|
100
114
|
- pronto
|
@@ -108,6 +122,7 @@ files:
|
|
108
122
|
- lib/pronto/formatter/text_formatter.rb
|
109
123
|
- lib/pronto/message.rb
|
110
124
|
- lib/pronto/plugin.rb
|
125
|
+
- lib/pronto/rake_task/travis_pull_request.rb
|
111
126
|
- lib/pronto/runner.rb
|
112
127
|
- lib/pronto/version.rb
|
113
128
|
- lib/pronto.rb
|
@@ -144,6 +159,6 @@ rubyforge_project:
|
|
144
159
|
rubygems_version: 2.0.7
|
145
160
|
signing_key:
|
146
161
|
specification_version: 4
|
147
|
-
summary:
|
162
|
+
summary: Pronto runs analysis quickly by checking only the introduced changes
|
148
163
|
test_files: []
|
149
164
|
has_rdoc:
|