pronto 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pronto.rb +20 -16
- data/lib/pronto/cli.rb +6 -1
- data/lib/pronto/formatter/formatter.rb +1 -0
- data/lib/pronto/formatter/github_formatter.rb +9 -22
- data/lib/pronto/formatter/github_pull_request_formatter.rb +41 -0
- data/lib/pronto/git/line.rb +44 -0
- data/lib/pronto/git/patch.rb +41 -0
- data/lib/pronto/git/patches.rb +24 -0
- data/lib/pronto/git/remote.rb +10 -0
- data/lib/pronto/git/repository.rb +68 -0
- data/lib/pronto/github.rb +55 -0
- data/lib/pronto/message.rb +5 -1
- data/lib/pronto/rake_task/travis_pull_request.rb +0 -1
- data/lib/pronto/version.rb +1 -1
- metadata +26 -63
- data/lib/pronto/rugged/commit.rb +0 -9
- data/lib/pronto/rugged/diff.rb +0 -6
- data/lib/pronto/rugged/diff/delta.rb +0 -16
- data/lib/pronto/rugged/diff/line.rb +0 -63
- data/lib/pronto/rugged/diff/patch.rb +0 -21
- data/lib/pronto/rugged/remote.rb +0 -8
- data/lib/pronto/rugged/repository.rb +0 -11
- data/lib/pronto/rugged/tree.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eab403503e8dbeb40f3d944afe3e66d7a6cabca2
|
4
|
+
data.tar.gz: d57522b4873da0a0ea3f2034107469f026c33e0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4ede27aa270973fb03c9ba2b1431f1cf9e1cef42b527719f66b9aa3ac855cdb7e352b59bd21de000bc47c5af19f44b778229e319adece9a9a5f342ee2a3d36e
|
7
|
+
data.tar.gz: 345071ecbe13dd72c6d3dbfb807bbf345317d72cacf9bf3fbcb9f009c861f9154b09bbd248c37db33006fe6773fbd044ffd246c5072fd99dce886913610a5e35
|
data/lib/pronto.rb
CHANGED
@@ -1,34 +1,38 @@
|
|
1
1
|
require 'rugged'
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
|
5
|
-
require 'pronto/
|
6
|
-
require 'pronto/
|
7
|
-
require 'pronto/
|
8
|
-
require 'pronto/
|
9
|
-
require 'pronto/
|
2
|
+
require 'octokit'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
require 'pronto/git/repository'
|
6
|
+
require 'pronto/git/patches'
|
7
|
+
require 'pronto/git/patch'
|
8
|
+
require 'pronto/git/line'
|
9
|
+
require 'pronto/git/remote'
|
10
10
|
|
11
11
|
require 'pronto/plugin'
|
12
12
|
require 'pronto/message'
|
13
13
|
require 'pronto/runner'
|
14
|
+
require 'pronto/github'
|
14
15
|
|
15
16
|
require 'pronto/formatter/text_formatter'
|
16
17
|
require 'pronto/formatter/json_formatter'
|
17
18
|
require 'pronto/formatter/github_formatter'
|
19
|
+
require 'pronto/formatter/github_pull_request_formatter'
|
18
20
|
require 'pronto/formatter/checkstyle_formatter'
|
19
21
|
require 'pronto/formatter/formatter'
|
20
22
|
|
21
23
|
module Pronto
|
22
24
|
def self.run(commit = 'master', repo_path = '.', formatter = nil)
|
23
|
-
repo = Rugged::Repository.new(repo_path)
|
24
25
|
commit ||= 'master'
|
25
|
-
merge_base = repo.merge_base(commit, repo.head.target)
|
26
|
-
patches = repo.diff(merge_base, repo.head.target)
|
27
26
|
|
28
|
-
|
27
|
+
repo = Git::Repository.new(repo_path)
|
28
|
+
patches = repo.diff(commit)
|
29
|
+
|
30
|
+
result = run_all_runners(patches)
|
29
31
|
|
30
32
|
formatter ||= default_formatter
|
31
|
-
formatter.format(result, repo)
|
33
|
+
puts formatter.format(result, repo)
|
34
|
+
|
35
|
+
result
|
32
36
|
end
|
33
37
|
|
34
38
|
def self.gem_names
|
@@ -37,7 +41,7 @@ module Pronto
|
|
37
41
|
true
|
38
42
|
elsif gem.name != 'pronto'
|
39
43
|
runner_path = File.join(gem.full_gem_path, "lib/pronto/#{gem.name}.rb")
|
40
|
-
File.
|
44
|
+
File.exist?(runner_path)
|
41
45
|
end
|
42
46
|
end
|
43
47
|
|
@@ -48,9 +52,9 @@ module Pronto
|
|
48
52
|
|
49
53
|
private
|
50
54
|
|
51
|
-
def self.run_all_runners(patches
|
55
|
+
def self.run_all_runners(patches)
|
52
56
|
Runner.runners.map do |runner|
|
53
|
-
runner.new.run(patches, commit)
|
57
|
+
runner.new.run(patches, patches.commit)
|
54
58
|
end.flatten.compact
|
55
59
|
end
|
56
60
|
|
data/lib/pronto/cli.rb
CHANGED
@@ -14,6 +14,10 @@ module Pronto
|
|
14
14
|
|
15
15
|
desc 'run', 'Run Pronto'
|
16
16
|
|
17
|
+
method_option :'exit-code',
|
18
|
+
type: :boolean,
|
19
|
+
banner: 'Exits with non-zero code if there were any warnings/errors.'
|
20
|
+
|
17
21
|
method_option :commit,
|
18
22
|
type: :string,
|
19
23
|
default: 'master',
|
@@ -39,7 +43,8 @@ module Pronto
|
|
39
43
|
end
|
40
44
|
|
41
45
|
formatter = ::Pronto::Formatter.get(options[:formatter])
|
42
|
-
|
46
|
+
messages = ::Pronto.run(options[:commit], '.', formatter)
|
47
|
+
exit(messages.count) if options[:'exit-code']
|
43
48
|
rescue Rugged::RepositoryError
|
44
49
|
puts '"pronto" should be run from a git repository'
|
45
50
|
end
|
@@ -1,17 +1,16 @@
|
|
1
|
-
require 'octokit'
|
2
|
-
|
3
1
|
module Pronto
|
4
2
|
module Formatter
|
5
3
|
class GithubFormatter
|
6
4
|
def format(messages, repo)
|
7
5
|
commit_messages = messages.map do |message|
|
8
|
-
github_slug = repo.
|
6
|
+
github_slug = repo.github_slug
|
9
7
|
sha = message.commit_sha
|
10
|
-
position = message.line.commit_line.position if message.line
|
11
|
-
path = message.path
|
12
8
|
body = message.msg
|
9
|
+
path = message.path
|
10
|
+
position = message.line.commit_line.position if message.line
|
13
11
|
|
14
|
-
|
12
|
+
comment = Github::Comment.new(github_slug, sha, body, path, position)
|
13
|
+
create_comment(github_slug, sha, comment)
|
15
14
|
end
|
16
15
|
|
17
16
|
"#{commit_messages.compact.count} Pronto messages posted to GitHub"
|
@@ -19,26 +18,14 @@ module Pronto
|
|
19
18
|
|
20
19
|
private
|
21
20
|
|
22
|
-
def create_comment(repo, sha,
|
21
|
+
def create_comment(repo, sha, comment)
|
23
22
|
comments = client.commit_comments(repo, sha)
|
24
|
-
|
25
|
-
|
26
|
-
comment.position == position &&
|
27
|
-
comment.path == path &&
|
28
|
-
comment.body == body
|
29
|
-
end
|
30
|
-
|
31
|
-
unless existing_comment
|
32
|
-
client.create_commit_comment(repo, sha, body, path, nil, position)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def access_token
|
37
|
-
ENV['GITHUB_ACCESS_TOKEN']
|
23
|
+
existing = comments.any? { |c| comment == c }
|
24
|
+
client.create_commit_comment(repo, sha, comment) unless existing
|
38
25
|
end
|
39
26
|
|
40
27
|
def client
|
41
|
-
@client ||=
|
28
|
+
@client ||= Github.new
|
42
29
|
end
|
43
30
|
end
|
44
31
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pronto
|
2
|
+
module Formatter
|
3
|
+
class GithubPullRequestFormatter
|
4
|
+
def format(messages, repo)
|
5
|
+
commit_messages = messages.map do |message|
|
6
|
+
github_slug = repo.github_slug
|
7
|
+
body = message.msg
|
8
|
+
path = message.path
|
9
|
+
|
10
|
+
commits = repo.commits_until(message.commit_sha)
|
11
|
+
|
12
|
+
line = nil
|
13
|
+
sha = commits.find do |commit|
|
14
|
+
patches = repo.show_commit(commit)
|
15
|
+
line = patches.find_line(message.full_path, message.line.new_lineno)
|
16
|
+
line
|
17
|
+
end
|
18
|
+
|
19
|
+
position = line.position - 1
|
20
|
+
|
21
|
+
comment = Github::Comment.new(github_slug, sha, body, path, position)
|
22
|
+
create_comment(github_slug, sha, comment)
|
23
|
+
end
|
24
|
+
|
25
|
+
"#{commit_messages.compact.count} Pronto messages posted to GitHub"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def create_comment(repo, sha, comment)
|
31
|
+
comments = client.pull_comments(repo, sha)
|
32
|
+
existing = comments.any? { |c| comment == c }
|
33
|
+
client.create_pull_comment(repo, sha, comment) unless existing
|
34
|
+
end
|
35
|
+
|
36
|
+
def client
|
37
|
+
@client ||= Github.new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Pronto
|
2
|
+
module Git
|
3
|
+
class Line < Struct.new(:line, :patch, :hunk)
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
def_delegators :line, :addition?, :deletion?, :content, :new_lineno,
|
7
|
+
:old_lineno, :line_origin
|
8
|
+
|
9
|
+
def position
|
10
|
+
hunk_index = patch.hunks.find_index { |h| h.header == hunk.header }
|
11
|
+
line_index = patch.lines.find_index(line)
|
12
|
+
|
13
|
+
line_index + hunk_index + 1
|
14
|
+
end
|
15
|
+
|
16
|
+
def commit_sha
|
17
|
+
blame[:final_commit_id] if blame
|
18
|
+
end
|
19
|
+
|
20
|
+
def commit_line
|
21
|
+
@commit_line ||= begin
|
22
|
+
patches = patch.repo.show_commit(commit_sha)
|
23
|
+
|
24
|
+
result = patches.find_line(patch.new_file_full_path,
|
25
|
+
blame[:orig_start_line_number])
|
26
|
+
result || self # no commit_line means that it was just added
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def ==(other)
|
31
|
+
content == other.content &&
|
32
|
+
line_origin == other.line_origin &&
|
33
|
+
old_lineno == other.old_lineno &&
|
34
|
+
new_lineno == other.new_lineno
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def blame
|
40
|
+
@blame ||= patch.blame(new_lineno)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Pronto
|
2
|
+
module Git
|
3
|
+
class Patch < Struct.new(:patch, :repo)
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
def_delegators :patch, :delta, :hunks, :stat
|
7
|
+
|
8
|
+
def additions
|
9
|
+
stat[0]
|
10
|
+
end
|
11
|
+
|
12
|
+
def deletions
|
13
|
+
stat[1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def blame(lineno)
|
17
|
+
repo.blame(self, lineno)
|
18
|
+
end
|
19
|
+
|
20
|
+
def lines
|
21
|
+
@lines ||= begin
|
22
|
+
hunks.flat_map do |hunk|
|
23
|
+
hunk.lines.map { |line| Line.new(line, self, hunk) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def added_lines
|
29
|
+
lines.select(&:addition?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def deleted_lines
|
33
|
+
lines.select(&:deletion?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def new_file_full_path
|
37
|
+
repo.path.join(delta.new_file[:path])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pronto
|
2
|
+
module Git
|
3
|
+
class Patches
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
attr_reader :commit, :repo
|
7
|
+
|
8
|
+
def initialize(repo, commit, patches)
|
9
|
+
@commit = commit
|
10
|
+
@patches = patches.map { |patch| Git::Patch.new(patch, repo) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def each(&block)
|
14
|
+
@patches.each(&block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find_line(path, line)
|
18
|
+
patch = find { |p| p.new_file_full_path == path }
|
19
|
+
lines = patch ? patch.lines : []
|
20
|
+
lines.find { |l| l.new_lineno == line }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Pronto
|
4
|
+
module Git
|
5
|
+
class Repository
|
6
|
+
def initialize(path)
|
7
|
+
@repo = Rugged::Repository.new(path)
|
8
|
+
end
|
9
|
+
|
10
|
+
def github_slug
|
11
|
+
remotes.map(&:github_slug).compact.first
|
12
|
+
end
|
13
|
+
|
14
|
+
def diff(commit)
|
15
|
+
merge_base = merge_base(commit)
|
16
|
+
patches = @repo.diff(merge_base, head)
|
17
|
+
Patches.new(self, merge_base, patches)
|
18
|
+
end
|
19
|
+
|
20
|
+
def show_commit(sha)
|
21
|
+
return [] unless sha
|
22
|
+
|
23
|
+
commit = @repo.lookup(sha)
|
24
|
+
return [] if commit.parents.count != 1
|
25
|
+
|
26
|
+
# TODO: Rugged does not seem to support diffing against multiple parents
|
27
|
+
diff = commit.diff(reverse: true)
|
28
|
+
return [] if diff.nil?
|
29
|
+
|
30
|
+
Patches.new(self, sha, diff.patches)
|
31
|
+
end
|
32
|
+
|
33
|
+
def commits_until(sha)
|
34
|
+
result = []
|
35
|
+
@repo.walk('HEAD', Rugged::SORT_TOPO).take_while do |commit|
|
36
|
+
result << commit.oid
|
37
|
+
!commit.oid.start_with?(sha)
|
38
|
+
end
|
39
|
+
result
|
40
|
+
end
|
41
|
+
|
42
|
+
def path
|
43
|
+
Pathname.new(@repo.path).parent
|
44
|
+
end
|
45
|
+
|
46
|
+
def blame(patch, lineno)
|
47
|
+
Rugged::Blame.new(@repo, patch.delta.new_file[:path],
|
48
|
+
min_line: lineno, max_line: lineno,
|
49
|
+
track_copies_same_file: true,
|
50
|
+
track_copies_any_commit_copies: true)[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def merge_base(commit)
|
56
|
+
@repo.merge_base(commit, head)
|
57
|
+
end
|
58
|
+
|
59
|
+
def head
|
60
|
+
@repo.head.target
|
61
|
+
end
|
62
|
+
|
63
|
+
def remotes
|
64
|
+
@remotes ||= @repo.remotes.map { |remote| Remote.new(remote) }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Pronto
|
2
|
+
class Github
|
3
|
+
def initialize
|
4
|
+
@comment_cache = {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def pull_comments(repo, sha)
|
8
|
+
@comment_cache["#{repo}/#{pull_id}/#{sha}"] ||= begin
|
9
|
+
client.pull_comments(repo, pull_id).map do |comment|
|
10
|
+
Comment.new(repo, sha, comment.body, comment.path, comment.position)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def commit_comments(repo, sha)
|
16
|
+
@comment_cache["#{repo}/#{sha}"] ||= begin
|
17
|
+
client.commit_comments(repo, sha).map do |comment|
|
18
|
+
Comment.new(repo, sha, comment.body, comment.path, comment.position)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_commit_comment(repo, sha, comment)
|
24
|
+
client.create_commit_comment(repo, sha, comment.body, comment.path,
|
25
|
+
nil, comment.position)
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_pull_comment(repo, sha, comment)
|
29
|
+
client.create_pull_comment(repo, pull_id, comment.body, sha, comment.path,
|
30
|
+
comment.position)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def client
|
36
|
+
@client ||= Octokit::Client.new(access_token: access_token)
|
37
|
+
end
|
38
|
+
|
39
|
+
def pull_id
|
40
|
+
ENV['PULL_REQUEST_ID'].to_i
|
41
|
+
end
|
42
|
+
|
43
|
+
def access_token
|
44
|
+
ENV['GITHUB_ACCESS_TOKEN']
|
45
|
+
end
|
46
|
+
|
47
|
+
class Comment < Struct.new(:repo, :sha, :body, :path, :position)
|
48
|
+
def ==(other)
|
49
|
+
position == other.position &&
|
50
|
+
path == other.path &&
|
51
|
+
body == other.body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/pronto/message.rb
CHANGED
data/lib/pronto/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindaugas Mozūras
|
@@ -14,122 +14,86 @@ dependencies:
|
|
14
14
|
name: rugged
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.19.0
|
20
|
-
- - <=
|
17
|
+
- - ~>
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
19
|
+
version: 0.21.0
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.19.0
|
30
|
-
- - <=
|
24
|
+
- - ~>
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
26
|
+
version: 0.21.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: thor
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - ~>
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
-
- - '>='
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 0.19.1
|
33
|
+
version: 0.19.0
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
38
|
- - ~>
|
48
39
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
- - '>='
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 0.19.1
|
40
|
+
version: 0.19.0
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: octokit
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
56
44
|
requirements:
|
57
45
|
- - ~>
|
58
46
|
- !ruby/object:Gem::Version
|
59
|
-
version: '2
|
60
|
-
- - '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 2.7.1
|
47
|
+
version: '3.2'
|
63
48
|
type: :runtime
|
64
49
|
prerelease: false
|
65
50
|
version_requirements: !ruby/object:Gem::Requirement
|
66
51
|
requirements:
|
67
52
|
- - ~>
|
68
53
|
- !ruby/object:Gem::Version
|
69
|
-
version: '2
|
70
|
-
- - '>='
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 2.7.1
|
54
|
+
version: '3.2'
|
73
55
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
56
|
+
name: rake
|
75
57
|
requirement: !ruby/object:Gem::Requirement
|
76
58
|
requirements:
|
77
59
|
- - ~>
|
78
60
|
- !ruby/object:Gem::Version
|
79
|
-
version: '
|
80
|
-
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 2.5.0
|
83
|
-
type: :runtime
|
61
|
+
version: '10.3'
|
62
|
+
type: :development
|
84
63
|
prerelease: false
|
85
64
|
version_requirements: !ruby/object:Gem::Requirement
|
86
65
|
requirements:
|
87
66
|
- - ~>
|
88
67
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
- - '>='
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
version: 2.5.0
|
68
|
+
version: '10.3'
|
93
69
|
- !ruby/object:Gem::Dependency
|
94
|
-
name:
|
70
|
+
name: rspec
|
95
71
|
requirement: !ruby/object:Gem::Requirement
|
96
72
|
requirements:
|
97
73
|
- - ~>
|
98
74
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
100
|
-
- - '>='
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
version: 10.1.0
|
75
|
+
version: '3.0'
|
103
76
|
type: :development
|
104
77
|
prerelease: false
|
105
78
|
version_requirements: !ruby/object:Gem::Requirement
|
106
79
|
requirements:
|
107
80
|
- - ~>
|
108
81
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
110
|
-
- - '>='
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 10.1.0
|
82
|
+
version: '3.0'
|
113
83
|
- !ruby/object:Gem::Dependency
|
114
|
-
name: rspec
|
84
|
+
name: rspec-its
|
115
85
|
requirement: !ruby/object:Gem::Requirement
|
116
86
|
requirements:
|
117
87
|
- - ~>
|
118
88
|
- !ruby/object:Gem::Version
|
119
|
-
version: '
|
120
|
-
- - '>='
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 2.14.0
|
89
|
+
version: '1.0'
|
123
90
|
type: :development
|
124
91
|
prerelease: false
|
125
92
|
version_requirements: !ruby/object:Gem::Requirement
|
126
93
|
requirements:
|
127
94
|
- - ~>
|
128
95
|
- !ruby/object:Gem::Version
|
129
|
-
version: '
|
130
|
-
- - '>='
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 2.14.0
|
96
|
+
version: '1.0'
|
133
97
|
description: |2
|
134
98
|
Pronto runs analysis quickly by checking only the relevant changes. Created
|
135
99
|
to be used on pull requests, but suited for other scenarios as well. Perfect
|
@@ -149,19 +113,18 @@ files:
|
|
149
113
|
- lib/pronto/formatter/checkstyle_formatter.rb
|
150
114
|
- lib/pronto/formatter/formatter.rb
|
151
115
|
- lib/pronto/formatter/github_formatter.rb
|
116
|
+
- lib/pronto/formatter/github_pull_request_formatter.rb
|
152
117
|
- lib/pronto/formatter/json_formatter.rb
|
153
118
|
- lib/pronto/formatter/text_formatter.rb
|
119
|
+
- lib/pronto/git/line.rb
|
120
|
+
- lib/pronto/git/patch.rb
|
121
|
+
- lib/pronto/git/patches.rb
|
122
|
+
- lib/pronto/git/remote.rb
|
123
|
+
- lib/pronto/git/repository.rb
|
124
|
+
- lib/pronto/github.rb
|
154
125
|
- lib/pronto/message.rb
|
155
126
|
- lib/pronto/plugin.rb
|
156
127
|
- lib/pronto/rake_task/travis_pull_request.rb
|
157
|
-
- lib/pronto/rugged/commit.rb
|
158
|
-
- lib/pronto/rugged/diff.rb
|
159
|
-
- lib/pronto/rugged/diff/delta.rb
|
160
|
-
- lib/pronto/rugged/diff/line.rb
|
161
|
-
- lib/pronto/rugged/diff/patch.rb
|
162
|
-
- lib/pronto/rugged/remote.rb
|
163
|
-
- lib/pronto/rugged/repository.rb
|
164
|
-
- lib/pronto/rugged/tree.rb
|
165
128
|
- lib/pronto/runner.rb
|
166
129
|
- lib/pronto/version.rb
|
167
130
|
homepage: http://github.org/mmozuras/pronto
|
data/lib/pronto/rugged/commit.rb
DELETED
data/lib/pronto/rugged/diff.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module Rugged
|
2
|
-
class Diff
|
3
|
-
class Line
|
4
|
-
def patch
|
5
|
-
hunk.owner
|
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 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
|
-
diff = commit.show
|
30
|
-
patches = diff ? diff.patches : []
|
31
|
-
commit_patch = patches.find do |p|
|
32
|
-
patch.new_file_full_path == p.new_file_full_path
|
33
|
-
end
|
34
|
-
|
35
|
-
lines = commit_patch ? commit_patch.lines : []
|
36
|
-
result = lines.find { |l| blameline.lineno == l.new_lineno }
|
37
|
-
|
38
|
-
result || self # no commit_line means that it was just added
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def ==(other)
|
43
|
-
content == other.content &&
|
44
|
-
line_origin == other.line_origin &&
|
45
|
-
old_lineno == other.old_lineno &&
|
46
|
-
new_lineno == other.new_lineno
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def repo
|
52
|
-
patch.diff.tree.repo
|
53
|
-
end
|
54
|
-
|
55
|
-
def blameline
|
56
|
-
@blameline ||= begin
|
57
|
-
blamelines = repo.blame(patch.new_file_full_path).lines
|
58
|
-
blamelines.find { |line| line.lineno == new_lineno }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Rugged
|
2
|
-
class Diff
|
3
|
-
class Patch
|
4
|
-
def added_lines
|
5
|
-
lines.select(&:addition?)
|
6
|
-
end
|
7
|
-
|
8
|
-
def deleted_lines
|
9
|
-
lines.select(&:deletion?)
|
10
|
-
end
|
11
|
-
|
12
|
-
def new_file_full_path
|
13
|
-
delta.new_file_full_path
|
14
|
-
end
|
15
|
-
|
16
|
-
def lines
|
17
|
-
map(&:lines).flatten.compact
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/pronto/rugged/remote.rb
DELETED