git-lint 5.2.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.adoc +195 -137
  4. data/git-lint.gemspec +12 -9
  5. data/lib/git/lint/analyzer.rb +9 -11
  6. data/lib/git/lint/analyzers/abstract.rb +6 -11
  7. data/lib/git/lint/analyzers/commit_author_name.rb +1 -1
  8. data/lib/git/lint/analyzers/commit_body_bullet.rb +3 -1
  9. data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +3 -1
  10. data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +3 -1
  11. data/lib/git/lint/analyzers/commit_body_line_length.rb +1 -1
  12. data/lib/git/lint/analyzers/commit_body_phrase.rb +3 -1
  13. data/lib/git/lint/analyzers/commit_body_presence.rb +1 -1
  14. data/lib/git/lint/analyzers/commit_body_single_bullet.rb +3 -1
  15. data/lib/git/lint/analyzers/commit_body_tracker_shorthand.rb +3 -1
  16. data/lib/git/lint/analyzers/commit_signature.rb +3 -1
  17. data/lib/git/lint/analyzers/commit_subject_length.rb +1 -1
  18. data/lib/git/lint/analyzers/commit_subject_prefix.rb +5 -3
  19. data/lib/git/lint/analyzers/commit_subject_suffix.rb +3 -1
  20. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +3 -1
  21. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +1 -1
  22. data/lib/git/lint/analyzers/commit_trailer_format_key.rb +3 -1
  23. data/lib/git/lint/analyzers/commit_trailer_format_value.rb +3 -1
  24. data/lib/git/lint/analyzers/commit_trailer_issue_key.rb +3 -1
  25. data/lib/git/lint/analyzers/commit_trailer_issue_value.rb +3 -1
  26. data/lib/git/lint/analyzers/commit_trailer_signer_key.rb +3 -1
  27. data/lib/git/lint/analyzers/commit_trailer_signer_name.rb +1 -1
  28. data/lib/git/lint/analyzers/commit_trailer_tracker_key.rb +3 -1
  29. data/lib/git/lint/analyzers/commit_trailer_tracker_value.rb +3 -1
  30. data/lib/git/lint/cli/actions/analyze/branch.rb +8 -2
  31. data/lib/git/lint/cli/actions/analyze/commit.rb +7 -1
  32. data/lib/git/lint/cli/actions/hook.rb +8 -1
  33. data/lib/git/lint/cli/shell.rb +26 -26
  34. data/lib/git/lint/configuration/contract.rb +103 -0
  35. data/lib/git/lint/configuration/defaults.yml +177 -162
  36. data/lib/git/lint/configuration/model.rb +97 -0
  37. data/lib/git/lint/container.rb +17 -3
  38. data/lib/git/lint/rake/register.rb +1 -1
  39. data/lib/git/lint/reporters/style.rb +4 -4
  40. data.tar.gz.sig +0 -0
  41. metadata +62 -27
  42. metadata.gz.sig +0 -0
  43. data/lib/git/lint/cli/actions/config.rb +0 -35
  44. data/lib/git/lint/cli/actions/container.rb +0 -23
  45. data/lib/git/lint/cli/actions/import.rb +0 -13
  46. data/lib/git/lint/cli/parser.rb +0 -37
  47. data/lib/git/lint/cli/parsers/analyze.rb +0 -41
  48. data/lib/git/lint/cli/parsers/core.rb +0 -76
  49. data/lib/git/lint/configuration/content.rb +0 -26
  50. data/lib/git/lint/configuration/loader.rb +0 -50
  51. data/lib/git/lint/configuration/setting.rb +0 -25
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_collaborator_key_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.then do |key|
@@ -32,7 +32,7 @@ module Git
32
32
 
33
33
  private
34
34
 
35
- def minimum = settings.minimum
35
+ def minimum = configuration.commits_trailer_collaborator_name_minimum
36
36
  end
37
37
  end
38
38
  end
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_format_key_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.then do |key|
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_format_value_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.match?(pattern) && !trailer.value.match?(value_pattern)
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_issue_key_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.then do |key|
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_issue_value_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.match?(pattern) && !trailer.value.match?(value_pattern)
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_signer_key_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.then do |key|
@@ -32,7 +32,7 @@ module Git
32
32
 
33
33
  private
34
34
 
35
- def minimum = settings.minimum
35
+ def minimum = configuration.commits_trailer_signer_name_minimum
36
36
  end
37
37
  end
38
38
  end
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_tracker_key_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.then do |key|
@@ -20,7 +20,9 @@ module Git
20
20
 
21
21
  protected
22
22
 
23
- def load_filter_list = Kit::FilterList.new(settings.includes)
23
+ def load_filter_list
24
+ Kit::FilterList.new configuration.commits_trailer_tracker_value_includes
25
+ end
24
26
 
25
27
  def invalid_line? trailer
26
28
  trailer.key.match?(pattern) && !trailer.value.match?(value_pattern)
@@ -1,20 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Git
4
6
  module Lint
5
7
  module CLI
6
8
  module Actions
7
9
  module Analyze
8
10
  # Handles analyze action for branch.
9
- class Branch
11
+ class Branch < Sod::Action
10
12
  include Git::Lint::Import[:kernel, :logger]
11
13
 
14
+ description "Analyze current branch."
15
+
16
+ on %w[-b --branch]
17
+
12
18
  def initialize(analyzer: Analyzer.new, **)
13
19
  super(**)
14
20
  @analyzer = analyzer
15
21
  end
16
22
 
17
- def call
23
+ def call(*)
18
24
  parse
19
25
  rescue Errors::Base => error
20
26
  logger.error { error.message }
@@ -1,14 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Git
4
6
  module Lint
5
7
  module CLI
6
8
  module Actions
7
9
  module Analyze
8
10
  # Handles analyze action for single commit SHA
9
- class Commit
11
+ class Commit < Sod::Action
10
12
  include Git::Lint::Import[:git, :kernel, :logger]
11
13
 
14
+ description "Analyze specific commits."
15
+
16
+ on %w[-c --commit], argument: "a,b,c"
17
+
12
18
  def initialize(analyzer: Analyzer.new, **)
13
19
  super(**)
14
20
  @analyzer = analyzer
@@ -1,13 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+ require "sod/types/pathname"
5
+
3
6
  module Git
4
7
  module Lint
5
8
  module CLI
6
9
  module Actions
7
10
  # Handles unsaved Git commit action.
8
- class Hook
11
+ class Hook < Sod::Action
9
12
  include Git::Lint::Import[:git, :kernel, :logger]
10
13
 
14
+ description "Hook for analyzing unsaved commits."
15
+
16
+ on "--hook", argument: "PATH", type: Pathname
17
+
11
18
  def initialize(analyzer: Analyzer.new, **)
12
19
  super(**)
13
20
  @analyzer = analyzer
@@ -1,46 +1,46 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "core"
3
+ require "sod"
4
4
 
5
5
  module Git
6
6
  module Lint
7
7
  module CLI
8
8
  # The main Command Line Interface (CLI) object.
9
9
  class Shell
10
- include Actions::Import[
11
- :analyze_branch,
12
- :analyze_commit,
13
- :config,
14
- :hook,
15
- :specification,
16
- :logger
17
- ]
18
-
19
- def initialize(parser: Parser.new, **)
10
+ include Import[:defaults_path, :xdg_config, :specification]
11
+
12
+ def initialize(context: Sod::Context, dsl: Sod, **)
20
13
  super(**)
21
- @parser = parser
14
+ @context = context
15
+ @dsl = dsl
22
16
  end
23
17
 
24
- def call arguments = Core::EMPTY_ARRAY
25
- act_on parser.call(arguments)
26
- rescue OptionParser::ParseError, Errors::Base => error
27
- logger.error { error.message }
28
- end
18
+ def call(...) = cli.call(...)
29
19
 
30
20
  private
31
21
 
32
- attr_reader :parser
22
+ attr_reader :context, :dsl
23
+
24
+ def cli
25
+ context = build_context
26
+
27
+ dsl.new "git-lint", banner: specification.banner do
28
+ on(Sod::Prefabs::Commands::Config, context:)
33
29
 
34
- def act_on configuration
35
- case configuration
36
- in action_analyze: true, analyze_sha: nil then analyze_branch.call
37
- in action_analyze: true, analyze_sha: String => sha then analyze_commit.call sha
38
- in action_config: Symbol => action then config.call action
39
- in action_hook: Pathname => path then hook.call path
40
- in action_version: true then logger.info { specification.labeled_version }
41
- else logger.any { parser.to_s }
30
+ on "analyze", "Analyze branch or commit(s)." do
31
+ on Actions::Analyze::Branch
32
+ on Actions::Analyze::Commit
33
+ end
34
+
35
+ on Actions::Hook
36
+ on(Sod::Prefabs::Actions::Version, context:)
37
+ on Sod::Prefabs::Actions::Help, self
42
38
  end
43
39
  end
40
+
41
+ def build_context
42
+ context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
43
+ end
44
44
  end
45
45
  end
46
46
  end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/schema"
4
+ require "etcher"
5
+
6
+ Dry::Schema.load_extensions :monads
7
+
8
+ module Git
9
+ module Lint
10
+ module Configuration
11
+ Contract = Dry::Schema.Params do
12
+ required(:commits_author_capitalization_enabled).filled :bool
13
+ required(:commits_author_capitalization_severity).filled :string
14
+ required(:commits_author_email_enabled).filled :bool
15
+ required(:commits_author_email_severity).filled :string
16
+ required(:commits_author_name_enabled).filled :bool
17
+ required(:commits_author_name_severity).filled :string
18
+ required(:commits_author_name_minimum).filled :integer
19
+ required(:commits_body_bullet_enabled).filled :bool
20
+ required(:commits_body_bullet_severity).filled :string
21
+ required(:commits_body_bullet_excludes).array :string
22
+ required(:commits_body_bullet_capitalization_enabled).filled :bool
23
+ required(:commits_body_bullet_capitalization_severity).filled :string
24
+ required(:commits_body_bullet_capitalization_includes).array :string
25
+ required(:commits_body_bullet_delimiter_enabled).filled :bool
26
+ required(:commits_body_bullet_delimiter_severity).filled :string
27
+ required(:commits_body_bullet_delimiter_includes).array :string
28
+ required(:commits_body_leading_line_enabled).filled :bool
29
+ required(:commits_body_leading_line_severity).filled :string
30
+ required(:commits_body_line_length_enabled).filled :bool
31
+ required(:commits_body_line_length_severity).filled :string
32
+ required(:commits_body_line_length_maximum).filled :integer
33
+ required(:commits_body_paragraph_capitalization_enabled).filled :bool
34
+ required(:commits_body_paragraph_capitalization_severity).filled :string
35
+ required(:commits_body_phrase_enabled).filled :bool
36
+ required(:commits_body_phrase_severity).filled :string
37
+ required(:commits_body_phrase_excludes).array :string
38
+ required(:commits_body_presence_enabled).filled :bool
39
+ required(:commits_body_presence_severity).filled :string
40
+ required(:commits_body_presence_minimum).filled :integer
41
+ required(:commits_body_single_bullet_enabled).filled :bool
42
+ required(:commits_body_single_bullet_severity).filled :string
43
+ required(:commits_body_single_bullet_includes).array :string
44
+ required(:commits_body_tracker_shorthand_enabled).filled :bool
45
+ required(:commits_body_tracker_shorthand_severity).filled :string
46
+ required(:commits_body_tracker_shorthand_excludes).array :string
47
+ required(:commits_signature_enabled).filled :bool
48
+ required(:commits_signature_severity).filled :string
49
+ required(:commits_signature_includes).array :string
50
+ required(:commits_subject_length_enabled).filled :bool
51
+ required(:commits_subject_length_severity).filled :string
52
+ required(:commits_subject_length_maximum).filled :integer
53
+ required(:commits_subject_prefix_enabled).filled :bool
54
+ required(:commits_subject_prefix_severity).filled :string
55
+ required(:commits_subject_prefix_delimiter).filled :string
56
+ required(:commits_subject_prefix_includes).array :string
57
+ required(:commits_subject_suffix_enabled).filled :bool
58
+ required(:commits_subject_suffix_severity).filled :string
59
+ required(:commits_subject_suffix_excludes).array :string
60
+ required(:commits_trailer_collaborator_capitalization_enabled).filled :bool
61
+ required(:commits_trailer_collaborator_capitalization_severity).filled :string
62
+ required(:commits_trailer_collaborator_email_enabled).filled :bool
63
+ required(:commits_trailer_collaborator_email_severity).filled :string
64
+ required(:commits_trailer_collaborator_key_enabled).filled :bool
65
+ required(:commits_trailer_collaborator_key_severity).filled :string
66
+ required(:commits_trailer_collaborator_key_includes).array :string
67
+ required(:commits_trailer_collaborator_name_enabled).filled :bool
68
+ required(:commits_trailer_collaborator_name_severity).filled :string
69
+ required(:commits_trailer_collaborator_name_minimum).filled :integer
70
+ required(:commits_trailer_duplicate_enabled).filled :bool
71
+ required(:commits_trailer_duplicate_severity).filled :string
72
+ required(:commits_trailer_format_key_enabled).filled :bool
73
+ required(:commits_trailer_format_key_severity).filled :string
74
+ required(:commits_trailer_format_key_includes).array :string
75
+ required(:commits_trailer_format_value_enabled).filled :bool
76
+ required(:commits_trailer_format_value_severity).filled :string
77
+ required(:commits_trailer_format_value_includes).array :string
78
+ required(:commits_trailer_issue_key_enabled).filled :bool
79
+ required(:commits_trailer_issue_key_severity).filled :string
80
+ required(:commits_trailer_issue_key_includes).array :string
81
+ required(:commits_trailer_issue_value_enabled).filled :bool
82
+ required(:commits_trailer_issue_value_severity).filled :string
83
+ required(:commits_trailer_issue_value_includes).array :string
84
+ required(:commits_trailer_signer_capitalization_enabled).filled :bool
85
+ required(:commits_trailer_signer_capitalization_severity).filled :string
86
+ required(:commits_trailer_signer_email_enabled).filled :bool
87
+ required(:commits_trailer_signer_email_severity).filled :string
88
+ required(:commits_trailer_signer_key_enabled).filled :bool
89
+ required(:commits_trailer_signer_key_severity).filled :string
90
+ required(:commits_trailer_signer_key_includes).array :string
91
+ required(:commits_trailer_signer_name_enabled).filled :bool
92
+ required(:commits_trailer_signer_name_severity).filled :string
93
+ required(:commits_trailer_signer_name_minimum).filled :integer
94
+ required(:commits_trailer_tracker_key_enabled).filled :bool
95
+ required(:commits_trailer_tracker_key_severity).filled :string
96
+ required(:commits_trailer_tracker_key_includes).array :string
97
+ required(:commits_trailer_tracker_value_enabled).filled :bool
98
+ required(:commits_trailer_tracker_value_severity).filled :string
99
+ required(:commits_trailer_tracker_value_includes).array :string
100
+ end
101
+ end
102
+ end
103
+ end