pronto 0.11.1 → 0.11.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
  SHA256:
3
- metadata.gz: 544591a739632f48bdbe56cc7a006b02a8ce13a22c9fbc679d35a4d5e67a0b00
4
- data.tar.gz: 1fee173f0ab873998cc2920a576687a842485509bbef0bd4fc23c03703372d20
3
+ metadata.gz: cc92d09f9dae20d0ddfb42faca81ab52258623f2014a5c0a736466f443996b00
4
+ data.tar.gz: 1d1c524e047a717e33d11f993d3e6fa6fc5b4103e9b75b1ae8c1275d7404394b
5
5
  SHA512:
6
- metadata.gz: b172a79ba57c6319761945212c7d8991adfafb4fdb6a3a91d9dea587a2099859bc5b052e0c54f694a5760b5f98d1a32e146d5811cbaf45d85afbf3c1204526a3
7
- data.tar.gz: ea63d5bb296cebc7628af1d1d20a93877cd40ac297954bbe898b7e7b8137482e2c516755c4ea63ef8ca2ee8c60331a39d3c9be6edc4aeab609a816c8ff9bc720
6
+ metadata.gz: 73d534c7929826919482802d0630f73a566e4525a2ffef4fe3a8f9ff1acce051b7dfbe77a01835ba483e6a5d977ddb39b18f455b832773e6e3e32ac9358b9f5a
7
+ data.tar.gz: 7c9f9c8ecaa21d3d1860c9da8ddebcfcf61d88deff3717b599c3fd65a0623c33ec76f99f34bd773f0f5d3832129295531c8d7e10ccb205b4714f809a6fc906d8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.2
4
+
5
+ ### Changes
6
+
7
+ * [#449](https://github.com/prontolabs/pronto/pull/449) relax octokit version dependency to allow releases up to 8.0
8
+ * [#450](https://github.com/prontolabs/pronto/pull/450) introduce Pronto::Formatter.register for adding custom formatters
9
+
3
10
  ## 0.11.1
4
11
 
5
12
  ### New features
@@ -2,7 +2,7 @@ module Pronto
2
2
  module Formatter
3
3
  class Base
4
4
  def self.name
5
- Formatter::FORMATTERS.invert[self]
5
+ raise NoMethodError, 'Must be implemented in subclasses.'
6
6
  end
7
7
 
8
8
  def config
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class BitbucketFormatter < CommitFormatter
4
+ def self.name
5
+ 'bitbucket'
6
+ end
7
+
4
8
  def client_module
5
9
  Bitbucket
6
10
  end
@@ -15,3 +19,5 @@ module Pronto
15
19
  end
16
20
  end
17
21
  end
22
+
23
+ Pronto::Formatter.register(Pronto::Formatter::BitbucketFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class BitbucketPullRequestFormatter < PullRequestFormatter
4
+ def self.name
5
+ 'bitbucket_pr'
6
+ end
7
+
4
8
  def client_module
5
9
  Bitbucket
6
10
  end
@@ -17,7 +21,7 @@ module Pronto
17
21
  return if config.bitbucket_auto_approve == false
18
22
 
19
23
  if comments_count > 0 && additions_count > 0
20
- client.unapprove_pull_request
24
+ client.unapprove_pull_request
21
25
  elsif comments_count == 0
22
26
  client.approve_pull_request
23
27
  end
@@ -25,3 +29,5 @@ module Pronto
25
29
  end
26
30
  end
27
31
  end
32
+
33
+ Pronto::Formatter.register(Pronto::Formatter::BitbucketPullRequestFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class BitbucketServerPullRequestFormatter < PullRequestFormatter
4
+ def self.name
5
+ 'bitbucket_server_pr'
6
+ end
7
+
4
8
  def client_module
5
9
  BitbucketServer
6
10
  end
@@ -15,3 +19,5 @@ module Pronto
15
19
  end
16
20
  end
17
21
  end
22
+
23
+ Pronto::Formatter.register(Pronto::Formatter::BitbucketServerPullRequestFormatter)
@@ -3,6 +3,10 @@ require 'rexml/document'
3
3
  module Pronto
4
4
  module Formatter
5
5
  class CheckstyleFormatter < Base
6
+ def self.name
7
+ 'checkstyle'
8
+ end
9
+
6
10
  def initialize
7
11
  @output = ''
8
12
  end
@@ -57,3 +61,5 @@ module Pronto
57
61
  end
58
62
  end
59
63
  end
64
+
65
+ Pronto::Formatter.register(Pronto::Formatter::CheckstyleFormatter)
@@ -1,30 +1,27 @@
1
1
  module Pronto
2
2
  module Formatter
3
- def self.get(names)
4
- names ||= 'text'
5
- Array(names).map { |name| FORMATTERS[name.to_s] || TextFormatter }
6
- .uniq.map(&:new)
7
- end
3
+ class << self
4
+ def register(formatter_klass)
5
+ unless formatter_klass.method_defined?(:format)
6
+ raise NoMethodError, "format method is not declared in the #{formatter_klass.name} class."
7
+ end
8
8
 
9
- def self.names
10
- FORMATTERS.keys
11
- end
9
+ base = Pronto::Formatter::Base
10
+ raise "#{formatter_klass.name} is not a #{base}" unless formatter_klass.ancestors.include?(base)
11
+
12
+ @formatters ||= {}
13
+ @formatters[formatter_klass.name] = formatter_klass
14
+ end
12
15
 
13
- FORMATTERS = {
14
- 'github' => GithubFormatter,
15
- 'github_status' => GithubStatusFormatter,
16
- 'github_combined_status' => GithubCombinedStatusFormatter,
17
- 'github_pr' => GithubPullRequestFormatter,
18
- 'github_pr_review' => GithubPullRequestReviewFormatter,
19
- 'gitlab' => GitlabFormatter,
20
- 'gitlab_mr' => GitlabMergeRequestReviewFormatter,
21
- 'bitbucket' => BitbucketFormatter,
22
- 'bitbucket_pr' => BitbucketPullRequestFormatter,
23
- 'bitbucket_server_pr' => BitbucketServerPullRequestFormatter,
24
- 'json' => JsonFormatter,
25
- 'checkstyle' => CheckstyleFormatter,
26
- 'text' => TextFormatter,
27
- 'null' => NullFormatter
28
- }.freeze
16
+ def get(names)
17
+ names ||= 'text'
18
+ Array(names).map { |name| @formatters[name.to_s] || TextFormatter }
19
+ .uniq.map(&:new)
20
+ end
21
+
22
+ def names
23
+ @formatters.keys
24
+ end
25
+ end
29
26
  end
30
27
  end
@@ -2,7 +2,11 @@ require_relative 'github_status_formatter/status_builder'
2
2
 
3
3
  module Pronto
4
4
  module Formatter
5
- class GithubCombinedStatusFormatter
5
+ class GithubCombinedStatusFormatter < Base
6
+ def self.name
7
+ 'github_combined_status'
8
+ end
9
+
6
10
  def format(messages, repo, _)
7
11
  client = Github.new(repo)
8
12
  head = repo.head_commit_sha
@@ -22,3 +26,5 @@ module Pronto
22
26
  end
23
27
  end
24
28
  end
29
+
30
+ Pronto::Formatter.register(Pronto::Formatter::GithubCombinedStatusFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class GithubFormatter < CommitFormatter
4
+ def self.name
5
+ 'github'
6
+ end
7
+
4
8
  def client_module
5
9
  Github
6
10
  end
@@ -15,3 +19,5 @@ module Pronto
15
19
  end
16
20
  end
17
21
  end
22
+
23
+ Pronto::Formatter.register(Pronto::Formatter::GithubFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class GithubPullRequestFormatter < PullRequestFormatter
4
+ def self.name
5
+ 'github_pr'
6
+ end
7
+
4
8
  def client_module
5
9
  Github
6
10
  end
@@ -16,3 +20,5 @@ module Pronto
16
20
  end
17
21
  end
18
22
  end
23
+
24
+ Pronto::Formatter.register(Pronto::Formatter::GithubPullRequestFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class GithubPullRequestReviewFormatter < PullRequestFormatter
4
+ def self.name
5
+ 'github_pr_review'
6
+ end
7
+
4
8
  def client_module
5
9
  Github
6
10
  end
@@ -22,3 +26,5 @@ module Pronto
22
26
  end
23
27
  end
24
28
  end
29
+
30
+ Pronto::Formatter.register(Pronto::Formatter::GithubPullRequestReviewFormatter)
@@ -1,6 +1,6 @@
1
1
  module Pronto
2
2
  module Formatter
3
- class GithubStatusFormatter
3
+ class GithubStatusFormatter < Base
4
4
  class Sentence
5
5
  def initialize(words)
6
6
  @words = words
@@ -2,7 +2,7 @@ require_relative 'sentence'
2
2
 
3
3
  module Pronto
4
4
  module Formatter
5
- class GithubStatusFormatter
5
+ class GithubStatusFormatter < Base
6
6
  class StatusBuilder
7
7
  def initialize(runner, messages)
8
8
  @runner = runner
@@ -2,7 +2,11 @@ require_relative 'github_status_formatter/status_builder'
2
2
 
3
3
  module Pronto
4
4
  module Formatter
5
- class GithubStatusFormatter
5
+ class GithubStatusFormatter < Base
6
+ def self.name
7
+ 'github_status'
8
+ end
9
+
6
10
  def format(messages, repo, _)
7
11
  client = Github.new(repo)
8
12
  head = repo.head_commit_sha
@@ -26,3 +30,5 @@ module Pronto
26
30
  end
27
31
  end
28
32
  end
33
+
34
+ Pronto::Formatter.register(Pronto::Formatter::GithubStatusFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class GitlabFormatter < CommitFormatter
4
+ def self.name
5
+ 'gitlab'
6
+ end
7
+
4
8
  def client_module
5
9
  Gitlab
6
10
  end
@@ -15,3 +19,5 @@ module Pronto
15
19
  end
16
20
  end
17
21
  end
22
+
23
+ Pronto::Formatter.register(Pronto::Formatter::GitlabFormatter)
@@ -1,6 +1,10 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class GitlabMergeRequestReviewFormatter < PullRequestFormatter
4
+ def self.name
5
+ 'gitlab_mr'
6
+ end
7
+
4
8
  def client_module
5
9
  Gitlab
6
10
  end
@@ -27,3 +31,5 @@ module Pronto
27
31
  end
28
32
  end
29
33
  end
34
+
35
+ Pronto::Formatter.register(Pronto::Formatter::GitlabMergeRequestReviewFormatter)
@@ -3,6 +3,10 @@ require 'json'
3
3
  module Pronto
4
4
  module Formatter
5
5
  class JsonFormatter < Base
6
+ def self.name
7
+ 'json'
8
+ end
9
+
6
10
  def format(messages, _repo, _patches)
7
11
  messages.map do |message|
8
12
  lineno = message.line.new_lineno if message.line
@@ -18,3 +22,5 @@ module Pronto
18
22
  end
19
23
  end
20
24
  end
25
+
26
+ Pronto::Formatter.register(Pronto::Formatter::JsonFormatter)
@@ -1,7 +1,13 @@
1
1
  module Pronto
2
2
  module Formatter
3
3
  class NullFormatter < Base
4
+ def self.name
5
+ 'null'
6
+ end
7
+
4
8
  def format(_messages, _repo, _patches); end
5
9
  end
6
10
  end
7
11
  end
12
+
13
+ Pronto::Formatter.register(Pronto::Formatter::NullFormatter)
@@ -3,6 +3,10 @@ require 'pronto/formatter/text_message_decorator'
3
3
  module Pronto
4
4
  module Formatter
5
5
  class TextFormatter < Base
6
+ def self.name
7
+ 'text'
8
+ end
9
+
6
10
  def format(messages, _repo, _patches)
7
11
  messages.map do |message|
8
12
  message_format = config.message_format(self.class.name)
@@ -13,3 +17,5 @@ module Pronto
13
17
  end
14
18
  end
15
19
  end
20
+
21
+ Pronto::Formatter.register(Pronto::Formatter::TextFormatter)
@@ -1,6 +1,6 @@
1
1
  module Pronto
2
2
  module Version
3
- STRING = '0.11.1'.freeze
3
+ STRING = '0.11.2'.freeze
4
4
 
5
5
  MSG = '%s (running on %s %s %s)'.freeze
6
6
 
data/lib/pronto.rb CHANGED
@@ -35,6 +35,7 @@ require 'pronto/bitbucket_server'
35
35
 
36
36
  require 'pronto/formatter/colorizable'
37
37
  require 'pronto/formatter/base'
38
+ require 'pronto/formatter/formatter'
38
39
  require 'pronto/formatter/text_formatter'
39
40
  require 'pronto/formatter/json_formatter'
40
41
  require 'pronto/formatter/git_formatter'
@@ -52,7 +53,6 @@ require 'pronto/formatter/bitbucket_pull_request_formatter'
52
53
  require 'pronto/formatter/bitbucket_server_pull_request_formatter'
53
54
  require 'pronto/formatter/checkstyle_formatter'
54
55
  require 'pronto/formatter/null_formatter'
55
- require 'pronto/formatter/formatter'
56
56
 
57
57
  module Pronto
58
58
  def self.run(commit = nil, repo_path = '.',
data/pronto.gemspec CHANGED
@@ -42,7 +42,7 @@ Gem::Specification.new do |s|
42
42
 
43
43
  s.add_runtime_dependency('gitlab', '>= 4.4.0', '< 5.0')
44
44
  s.add_runtime_dependency('httparty', '>= 0.13.7', '< 1.0')
45
- s.add_runtime_dependency('octokit', '>= 4.7.0', '< 7.0')
45
+ s.add_runtime_dependency('octokit', '>= 4.7.0', '< 8.0')
46
46
  s.add_runtime_dependency('rainbow', '>= 2.2', '< 4.0')
47
47
  s.add_runtime_dependency('rexml', '>= 3.2.5', '< 4.0')
48
48
  s.add_runtime_dependency('rugged', '>= 0.23.0', '< 2.0')
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.11.1
4
+ version: 0.11.2
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: 2022-12-31 00:00:00.000000000 Z
11
+ date: 2023-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: 4.7.0
60
60
  - - "<"
61
61
  - !ruby/object:Gem::Version
62
- version: '7.0'
62
+ version: '8.0'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ dependencies:
69
69
  version: 4.7.0
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
- version: '7.0'
72
+ version: '8.0'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rainbow
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -401,7 +401,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
401
401
  - !ruby/object:Gem::Version
402
402
  version: '0'
403
403
  requirements: []
404
- rubygems_version: 3.0.9
404
+ rubygems_version: 3.3.15
405
405
  signing_key:
406
406
  specification_version: 4
407
407
  summary: Pronto runs analysis by checking only the introduced changes