pronto 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/pronto.rb +8 -7
- data/lib/pronto/formatter/github_formatter.rb +9 -23
- data/lib/pronto/rake_task/travis_pull_request.rb +3 -3
- data/lib/pronto/rugged/commit.rb +9 -0
- data/lib/pronto/rugged/diff/line.rb +37 -0
- data/lib/pronto/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85dc0a7bada137f7afa7bcebe1c07ea768cee9c7
|
4
|
+
data.tar.gz: b6448d7d62c19197b5480e6b02d37e7ff5329a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19a811421795f9d684e768342d875267a91152dbc1a1182a18c697788d5cbb92fec73a6454d80af1b2d7021123a749682cc92d7c22c6cbbd2c7eb57bfb29bc93
|
7
|
+
data.tar.gz: 1e048107685ea2175ce0d753823813c689932d4c8ebc7415cd429cd8a9d4a3e6afc68167db40e2db747cddfa606be8496cd4b4de0adaf782c8b459f4b15acc00
|
data/README.md
CHANGED
@@ -6,14 +6,15 @@
|
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
-
Pronto runs analysis quickly by checking only the introduced changes.
|
9
|
+
Pronto runs analysis quickly by checking only the introduced changes. Created
|
10
|
+
to be used on pull requets, but suited for other scenarios as well.
|
10
11
|
|
11
12
|
![Pronto demo](pronto.gif "")
|
12
13
|
|
13
14
|
### Pull Requests
|
14
15
|
|
15
|
-
You can run Pronto as part of your builds and then get results as
|
16
|
-
|
16
|
+
You can run Pronto as part of your builds and then get results as comments
|
17
|
+
using `GithubFormatter`.
|
17
18
|
|
18
19
|
Actually, Pronto runs Pronto whenever you make a pull request on Pronto. It
|
19
20
|
uses Travis CI and the included `TravisPullRequest` rake task for that.
|
data/lib/pronto.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rugged'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
require 'pronto/rugged/diff'
|
3
|
+
require 'pronto/rugged/diff/delta'
|
4
|
+
require 'pronto/rugged/diff/patch'
|
5
|
+
require 'pronto/rugged/diff/line'
|
6
|
+
require 'pronto/rugged/tree'
|
7
|
+
require 'pronto/rugged/remote'
|
8
|
+
require 'pronto/rugged/repository'
|
9
|
+
require 'pronto/rugged/commit'
|
9
10
|
|
10
11
|
require 'pronto/plugin'
|
11
12
|
require 'pronto/message'
|
@@ -6,12 +6,12 @@ module Pronto
|
|
6
6
|
def format(messages)
|
7
7
|
commit_messages = messages.map do |message|
|
8
8
|
repo = github_slug(message)
|
9
|
-
sha = commit_sha
|
10
|
-
position = message.line.position
|
9
|
+
sha = message.line.commit_sha
|
10
|
+
position = message.line.commit_line.position
|
11
11
|
path = message.path
|
12
12
|
body = message.msg
|
13
13
|
|
14
|
-
|
14
|
+
create_comment(repo, sha, position, path, body)
|
15
15
|
end
|
16
16
|
|
17
17
|
"#{commit_messages.compact.count} Pronto messages posted to GitHub"
|
@@ -19,15 +19,16 @@ module Pronto
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def create_comment(repo, sha, position, path, body)
|
23
|
+
comments = client.commit_comments(repo, sha)
|
24
|
+
|
25
|
+
existing_comment = comments.find do |comment|
|
26
|
+
comment.position == position &&
|
26
27
|
comment.path == path &&
|
27
28
|
comment.body == body
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
+
unless existing_comment
|
31
32
|
client.create_commit_comment(repo, sha, body, path, nil, position)
|
32
33
|
end
|
33
34
|
end
|
@@ -43,21 +44,6 @@ module Pronto
|
|
43
44
|
def github_slug(message)
|
44
45
|
message.repo.remotes.map(&:github_slug).compact.first
|
45
46
|
end
|
46
|
-
|
47
|
-
def commit_sha(message)
|
48
|
-
blamelines = blame(message).lines
|
49
|
-
lineno = message.line.new_lineno
|
50
|
-
|
51
|
-
blameline = blamelines.find { |line| line.lineno == lineno }
|
52
|
-
|
53
|
-
blameline.commit.id if blameline
|
54
|
-
end
|
55
|
-
|
56
|
-
def blame(message)
|
57
|
-
@blames ||= {}
|
58
|
-
@blames[message.path] ||= message.repo.blame(message.path)
|
59
|
-
@blames[message.path]
|
60
|
-
end
|
61
47
|
end
|
62
48
|
end
|
63
49
|
end
|
@@ -31,11 +31,11 @@ module Pronto
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def run_task(verbose)
|
34
|
-
return if
|
34
|
+
return if pull_id.nil? || pull_id == 'false'
|
35
35
|
|
36
36
|
client = Octokit::Client.new
|
37
37
|
|
38
|
-
pull_request = client.pull_request(repo_slug,
|
38
|
+
pull_request = client.pull_request(repo_slug, pull_id)
|
39
39
|
formatter = ::Pronto::Formatter::GithubFormatter.new
|
40
40
|
|
41
41
|
::Pronto.gem_names.each { |gem_name| require "pronto/#{gem_name}" }
|
@@ -44,7 +44,7 @@ module Pronto
|
|
44
44
|
|
45
45
|
private
|
46
46
|
|
47
|
-
def
|
47
|
+
def pull_id
|
48
48
|
ENV['TRAVIS_PULL_REQUEST']
|
49
49
|
end
|
50
50
|
|
@@ -12,12 +12,49 @@ module Rugged
|
|
12
12
|
line_index + hunk_index + 1
|
13
13
|
end
|
14
14
|
|
15
|
+
def commit
|
16
|
+
@commit ||= begin
|
17
|
+
repo.lookup(commit_sha) if commit_sha
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def commit_sha
|
22
|
+
@commit_sha ||= begin
|
23
|
+
blameline.commit.id if blameline
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def commit_line
|
28
|
+
@commit_line ||= begin
|
29
|
+
commit_patch = commit.show.patches.find do |p|
|
30
|
+
patch.new_file_full_path == p.new_file_full_path
|
31
|
+
end
|
32
|
+
|
33
|
+
commit_patch.lines.find do |l|
|
34
|
+
blameline.oldlineno == l.old_lineno
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
15
39
|
def ==(other)
|
16
40
|
content == other.content &&
|
17
41
|
line_origin == other.line_origin &&
|
18
42
|
old_lineno == other.old_lineno &&
|
19
43
|
new_lineno == other.new_lineno
|
20
44
|
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def repo
|
49
|
+
patch.diff.tree.repo
|
50
|
+
end
|
51
|
+
|
52
|
+
def blameline
|
53
|
+
@blameline ||= begin
|
54
|
+
blamelines = repo.blame(patch.new_file_full_path).lines
|
55
|
+
blamelines.find { |line| line.lineno == new_lineno }
|
56
|
+
end
|
57
|
+
end
|
21
58
|
end
|
22
59
|
end
|
23
60
|
end
|
data/lib/pronto/version.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.4
|
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-10-
|
11
|
+
date: 2013-10-06 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.3.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.3.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: grit
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/pronto/message.rb
|
124
124
|
- lib/pronto/plugin.rb
|
125
125
|
- lib/pronto/rake_task/travis_pull_request.rb
|
126
|
+
- lib/pronto/rugged/commit.rb
|
126
127
|
- lib/pronto/rugged/diff/delta.rb
|
127
128
|
- lib/pronto/rugged/diff/line.rb
|
128
129
|
- lib/pronto/rugged/diff/patch.rb
|