pronto 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 672a87b463cba4d6e380e0f87ff04d8e7d6cf12c
4
- data.tar.gz: c851282dc64d81f130401012827e7ce7b4ce1646
3
+ metadata.gz: e6606bb1e1a787c844899c0ade07a848ce88015f
4
+ data.tar.gz: 570c767d2f9c327aac7a68c9969849268472c429
5
5
  SHA512:
6
- metadata.gz: dfa5641018ebabc4b198cdc37d9796cffce0fefa66edb2a5fef6f05f0e6733ae1c86899884d8c5873e7e329795962b3fb42c3290fd78001916df740cd74a11d8
7
- data.tar.gz: 6e46e4a215ab0a39d1c08d55180a837fc2df431102d81587f9e2d1a9ecf1cf463246434cd31ce2de91bf262ba9ec85711addd8bfca7c517c60a7708e7faa3223
6
+ metadata.gz: 595ba658edf9f057540e2c990e4e6a84535c467757cd3bd434c027d74ffdaa2c95f2b14082592158d90b17efc3ce58bfd278a8ce10bc4791adc13662202d4881
7
+ data.tar.gz: a2784022f00ba634bf0d84df9994659f5f9f9c75a5df5220ffb38a7906058a22e37c874fc6cc5cdf9b0d75b61e60706c4901495d915bc13f3de68bbbc261f03b
data/lib/pronto.rb CHANGED
@@ -19,11 +19,15 @@ require 'pronto/formatter/formatter'
19
19
 
20
20
  module Pronto
21
21
  def self.run(commit = 'master', repo_path = '.', formatter = nil)
22
- patches = diff(repo_path, commit)
23
- result = run_all_runners(patches, commit)
22
+ repo = Rugged::Repository.new(repo_path)
23
+ commit ||= 'master'
24
+ merge_base = repo.merge_base(commit, repo.head.target)
25
+ patches = repo.diff(merge_base, repo.head.target)
26
+
27
+ result = run_all_runners(patches, merge_base)
24
28
 
25
29
  formatter ||= default_formatter
26
- formatter.format(result)
30
+ formatter.format(result, repo)
27
31
  end
28
32
 
29
33
  def self.gem_names
@@ -43,13 +47,6 @@ module Pronto
43
47
 
44
48
  private
45
49
 
46
- def self.diff(repo_path, commit)
47
- repo = Rugged::Repository.new(repo_path)
48
- commit ||= 'master'
49
- merge_base = repo.merge_base(commit, repo.head.target)
50
- repo.diff(merge_base, repo.head.target)
51
- end
52
-
53
50
  def self.run_all_runners(patches, commit)
54
51
  Runner.runners.map do |runner|
55
52
  runner.new.run(patches, commit)
@@ -3,15 +3,15 @@ require 'octokit'
3
3
  module Pronto
4
4
  module Formatter
5
5
  class GithubFormatter
6
- def format(messages)
6
+ def format(messages, repo)
7
7
  commit_messages = messages.map do |message|
8
- repo = github_slug(message)
8
+ github_slug = repo.remotes.map(&:github_slug).compact.first
9
9
  sha = message.commit_sha
10
10
  position = message.line.commit_line.position if message.line
11
11
  path = message.path
12
12
  body = message.msg
13
13
 
14
- create_comment(repo, sha, position, path, body)
14
+ create_comment(github_slug, sha, position, path, body)
15
15
  end
16
16
 
17
17
  "#{commit_messages.compact.count} Pronto messages posted to GitHub"
@@ -40,10 +40,6 @@ module Pronto
40
40
  def client
41
41
  @client ||= Octokit::Client.new(access_token: access_token)
42
42
  end
43
-
44
- def github_slug(message)
45
- message.repo.remotes.map(&:github_slug).compact.first
46
- end
47
43
  end
48
44
  end
49
45
  end
@@ -3,7 +3,7 @@ require 'json'
3
3
  module Pronto
4
4
  module Formatter
5
5
  class JsonFormatter
6
- def format(messages)
6
+ def format(messages, _)
7
7
  messages.map do |message|
8
8
  lineno = message.line.new_lineno if message.line
9
9
 
@@ -1,7 +1,7 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class TextFormatter
4
- def format(messages)
4
+ def format(messages, _)
5
5
  messages.map do |message|
6
6
  level = message.level[0].upcase
7
7
  line = message.line
@@ -18,7 +18,7 @@ module Pronto
18
18
  end
19
19
 
20
20
  def repo
21
- line.patch.delta.repo
21
+ line.patch.delta.repo if line
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Pronto
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
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.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 2.3.0
47
+ version: 2.4.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.3.0
54
+ version: 2.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: grit
57
57
  requirement: !ruby/object:Gem::Requirement