git-lint 10.3.0 → 11.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0579e354abdcbf74f13138b3380d58268cfe02847d140a798bb76ac91fbd6fbf'
4
- data.tar.gz: 1da76b63c393d595dfcc3ff01115bf1f36d51393b34469858bb29aed2cecfec3
3
+ metadata.gz: '09bc2331e668a1ed5e6851a60926668d1d392f4addd54a49ffed7fba63d78fcd'
4
+ data.tar.gz: b5937a91c8e8e100e054ef5209f5eb594c8facbca2fbd974acf637f3a147527d
5
5
  SHA512:
6
- metadata.gz: c913dfcd75ba482a13fada4abadbbc05f2a532300bd4f3447ac8afe101e7eeeda5c4f721cdfe9f4018fe2982bf74de462b42736c8c65661ae348e7e3b2a44e6f
7
- data.tar.gz: 7d2a6722730e23745716ae618d306a8931dc3361c7b58f389eb721b4ba15d1369c76514505723eebcb572f949ef8ac0b3b0e2ad5d860cec7adc44fea58603a9c
6
+ metadata.gz: 6219f9cd5dad3b933a99ce75873c2f9bc8142f5cbf03c6886d2351b29fb1575396b2f4ddc0aff045b0cad546fe14419bd34d90dc1b6262a978d9991523e42a2c
7
+ data.tar.gz: a98ad6176494113b9eec2cde32f24412f6e4c361e240afed7260c90cc8e50f384f3d3a23a85f49e430566392d26e619d25fc066b5420f893257bd1642d88f009
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -142,6 +142,9 @@ commits:
142
142
  paragraph_capitalization:
143
143
  enabled: true
144
144
  severity: error
145
+ paragraph_new_line:
146
+ enabled: true
147
+ severity: error
145
148
  phrase:
146
149
  enabled: true
147
150
  severity: error
@@ -228,6 +231,11 @@ commits:
228
231
  collaborator_email:
229
232
  enabled: true
230
233
  severity: error
234
+ excludes:
235
+ - "agent@"
236
+ - "codex@"
237
+ - "copilot@"
238
+ - "noreply"
231
239
  collaborator_key:
232
240
  enabled: true
233
241
  severity: error
@@ -258,6 +266,7 @@ commits:
258
266
  milestone_key:
259
267
  enabled: true
260
268
  severity: error
269
+ mandatory: true
261
270
  milestone_value:
262
271
  enabled: true
263
272
  severity: error
@@ -525,6 +534,26 @@ Curabitur eleifend wisi iaculis ipsum.
525
534
  * link:https://docs.asciidoctor.org/asciidoc/latest/macros/links[Links]
526
535
  * link:https://docs.asciidoctor.org/asciidoc/latest/macros/xref[Cross references]
527
536
 
537
+ ==== Commit Body Paragraph New Line
538
+
539
+ [options="header"]
540
+ |===
541
+ | Enabled | Severity | Defaults
542
+ | true | error | none
543
+ |===
544
+
545
+ Ensures each paragraph of the commit body doesn't use excessive new lines. This allows paragraphs to grow/shrink based on screen size for improved readability.
546
+
547
+ ....
548
+ # Disallowed
549
+ Pellentque morbi-trist sentus et netus
550
+ et malesuada fames ac turpis egestas.
551
+ Vestibulum tortor quam.
552
+
553
+ # Allowed
554
+ Pellentque morbi-trist sentus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam.
555
+ ....
556
+
528
557
  ==== Commit Body Phrase
529
558
 
530
559
  [options="header"]
@@ -765,7 +794,7 @@ Shepherd Derrial Book
765
794
  [options="header"]
766
795
  |===
767
796
  | Enabled | Severity | Defaults
768
- | true | error | none
797
+ | true | error | excludes: (see configuration)
769
798
  |===
770
799
 
771
800
  Ensures collaborator email address is valid for commit trailer.
@@ -774,6 +803,9 @@ Ensures collaborator email address is valid for commit trailer.
774
803
  # Disallowed
775
804
  Co-authored-by: River Tam <invalid>
776
805
 
806
+ # Disallowed
807
+ Co-authored-by: LLM <agent@slopware.io>
808
+
777
809
  # Allowed
778
810
  Co-authored-by: River Tam <river@firefly.com>
779
811
  ....
@@ -910,13 +942,15 @@ Issue: 123
910
942
 
911
943
  [options="header"]
912
944
  |===
913
- | Enabled | Severity
914
- | true | error
945
+ | Enabled | Severity | Manditory
946
+ | true | error | true
915
947
  |===
916
948
 
917
- Ensures milestone trailer key is correct format.
949
+ Ensures milestone trailer key is present and in correct format.
918
950
 
919
951
  ....
952
+ # Disallowed (missing)
953
+
920
954
  # Disallowed
921
955
  milestone: patch
922
956
 
@@ -924,6 +958,8 @@ milestone: patch
924
958
  Milestone: patch
925
959
  ....
926
960
 
961
+ This key is mandatory by default which means the key must always be present unless the repository is unpublished (i.e. has no origin). When the repository is unpublished, this gives you the freedom to release your initial version (i.e. 0.0.0) without this trailer. Once published, you'll need the trailer. To make the key optional, set mandatory to `false`.
962
+
927
963
  ==== Commit Trailer Milestone Value
928
964
 
929
965
  [options="header"]
data/git-lint.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "git-lint"
5
- spec.version = "10.3.0"
5
+ spec.version = "11.0.0"
6
6
  spec.authors = ["Brooke Kuhlmann"]
7
7
  spec.email = ["brooke@alchemists.io"]
8
8
  spec.homepage = "https://alchemists.io/projects/git-lint"
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "dry-monads", "~> 1.9"
31
31
  spec.add_dependency "dry-schema", "~> 1.15"
32
32
  spec.add_dependency "etcher", "~> 4.3"
33
- spec.add_dependency "gitt", "~> 5.0"
33
+ spec.add_dependency "gitt", "~> 5.3"
34
34
  spec.add_dependency "infusible", "~> 5.0"
35
35
  spec.add_dependency "refinements", "~> 14.0"
36
36
  spec.add_dependency "runcom", "~> 13.0"
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Git
4
+ module Lint
5
+ module Analyzers
6
+ # Analyzes proper capitalization of commit body paragraphs.
7
+ class CommitBodyParagraphNewLine < Abstract
8
+ PATTERN = /
9
+ \n # New line.
10
+ (?! # Negative lookahead start.
11
+ \s{1,} # Indentation.
12
+ | # Or.
13
+ \s* # Optional whitespace.
14
+ \# # Comment character.
15
+ ) # Negative lookahead end.
16
+ /mx
17
+
18
+ def initialize(commit, pattern: PATTERN, **)
19
+ super(commit, **)
20
+ @pattern = pattern
21
+ end
22
+
23
+ def valid? = invalids.empty?
24
+
25
+ def issue
26
+ return {} if valid?
27
+
28
+ {
29
+ hint: "Avoid unnecessary new lines.",
30
+ lines: affected_lines
31
+ }
32
+ end
33
+
34
+ private
35
+
36
+ attr_reader :pattern
37
+
38
+ def affected_lines
39
+ invalids.each.with_object [] do |line, lines|
40
+ lines << self.class.build_issue_line(commit.body_lines.index(line[/.+/]), line)
41
+ end
42
+ end
43
+
44
+ def invalids
45
+ @invalids ||= commit.body_paragraphs.grep pattern
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -17,15 +17,23 @@ module Git
17
17
  return {} if valid?
18
18
 
19
19
  {
20
- hint: %(Email must follow name and use format: "<name@server.domain>".),
20
+ hint: %(Use format: "<name@server.domain>". Avoid: #{filter_list.to_usage}.),
21
21
  lines: affected_commit_trailers
22
22
  }
23
23
  end
24
24
 
25
25
  protected
26
26
 
27
+ def load_filter_list
28
+ Kit::FilterList.new settings.commits_trailer_collaborator_email_excludes
29
+ end
30
+
27
31
  def invalid_line? trailer
28
- email = parser.call(trailer.value).email
32
+ value = trailer.value
33
+
34
+ return true if value.match?(/.*#{Regexp.union filter_list}.*/)
35
+
36
+ email = parser.call(value).email
29
37
  trailer.key.match?(setting.pattern) && !validator.call(email)
30
38
  end
31
39
 
@@ -5,15 +5,17 @@ module Git
5
5
  module Analyzers
6
6
  # Analyzes commit trailer milestone key usage.
7
7
  class CommitTrailerMilestoneKey < Abstract
8
- include Dependencies[setting: "trailers.milestone"]
8
+ include Dependencies[:git, setting: "trailers.milestone"]
9
9
 
10
- def valid? = affected_commit_trailers.empty?
10
+ def valid?
11
+ optional? && affected_commit_trailers.empty?
12
+ end
11
13
 
12
14
  def issue
13
15
  return {} if valid?
14
16
 
15
17
  {
16
- hint: "Use: #{filter_list.to_usage}.",
18
+ hint: "#{hint_prefix}: #{filter_list.to_usage}.",
17
19
  lines: affected_commit_trailers
18
20
  }
19
21
  end
@@ -27,6 +29,20 @@ module Git
27
29
  key.match?(setting.pattern) && !key.match?(/\A#{Regexp.union filter_list}\Z/)
28
30
  end
29
31
  end
32
+
33
+ private
34
+
35
+ def optional?
36
+ return true unless mandatory?
37
+
38
+ commit.trailers.any? { it.key == setting.name }
39
+ end
40
+
41
+ def mandatory? = settings.commits_trailer_milestone_key_mandatory && git.origin?
42
+
43
+ def hint_prefix
44
+ settings.commits_trailer_milestone_key_mandatory ? "Use (manditory)" : "Use"
45
+ end
30
46
  end
31
47
  end
32
48
  end
@@ -20,6 +20,7 @@ module Git
20
20
  Analyzers::CommitBodyLeadingLine,
21
21
  Analyzers::CommitBodyLineLength,
22
22
  Analyzers::CommitBodyParagraphCapitalization,
23
+ Analyzers::CommitBodyParagraphNewLine,
23
24
  Analyzers::CommitBodyPhrase,
24
25
  Analyzers::CommitBodyPresence,
25
26
  Analyzers::CommitBodyTrackerShorthand,
@@ -32,6 +32,8 @@ module Git
32
32
  required(:commits_body_line_length_maximum).filled :integer
33
33
  required(:commits_body_paragraph_capitalization_enabled).filled :bool
34
34
  required(:commits_body_paragraph_capitalization_severity).filled :string
35
+ required(:commits_body_paragraph_new_line_enabled).filled :bool
36
+ required(:commits_body_paragraph_new_line_severity).filled :string
35
37
  required(:commits_body_phrase_enabled).filled :bool
36
38
  required(:commits_body_phrase_severity).filled :string
37
39
  required(:commits_body_phrase_excludes).array :string
@@ -64,6 +66,7 @@ module Git
64
66
  required(:commits_trailer_collaborator_capitalization_severity).filled :string
65
67
  required(:commits_trailer_collaborator_email_enabled).filled :bool
66
68
  required(:commits_trailer_collaborator_email_severity).filled :string
69
+ required(:commits_trailer_collaborator_email_excludes).array :string
67
70
  required(:commits_trailer_collaborator_key_enabled).filled :bool
68
71
  required(:commits_trailer_collaborator_key_severity).filled :string
69
72
  required(:commits_trailer_collaborator_name_enabled).filled :bool
@@ -83,6 +86,7 @@ module Git
83
86
  required(:commits_trailer_issue_value_includes).array :string
84
87
  required(:commits_trailer_milestone_key_enabled).filled :bool
85
88
  required(:commits_trailer_milestone_key_severity).filled :string
89
+ required(:commits_trailer_milestone_key_mandatory).filled :bool
86
90
  required(:commits_trailer_milestone_value_enabled).filled :bool
87
91
  required(:commits_trailer_milestone_value_severity).filled :string
88
92
  required(:commits_trailer_milestone_value_includes).array :string
@@ -39,6 +39,9 @@ commits:
39
39
  paragraph_capitalization:
40
40
  enabled: true
41
41
  severity: error
42
+ paragraph_new_line:
43
+ enabled: true
44
+ severity: error
42
45
  phrase:
43
46
  enabled: true
44
47
  severity: error
@@ -125,6 +128,11 @@ commits:
125
128
  collaborator_email:
126
129
  enabled: true
127
130
  severity: error
131
+ excludes:
132
+ - "agent@"
133
+ - "codex@"
134
+ - "copilot@"
135
+ - "noreply"
128
136
  collaborator_key:
129
137
  enabled: true
130
138
  severity: error
@@ -155,6 +163,7 @@ commits:
155
163
  milestone_key:
156
164
  enabled: true
157
165
  severity: error
166
+ mandatory: true
158
167
  milestone_value:
159
168
  enabled: true
160
169
  severity: error
@@ -27,6 +27,8 @@ module Git
27
27
  :commits_body_line_length_maximum,
28
28
  :commits_body_paragraph_capitalization_enabled,
29
29
  :commits_body_paragraph_capitalization_severity,
30
+ :commits_body_paragraph_new_line_enabled,
31
+ :commits_body_paragraph_new_line_severity,
30
32
  :commits_body_phrase_enabled,
31
33
  :commits_body_phrase_severity,
32
34
  :commits_body_phrase_excludes,
@@ -59,6 +61,7 @@ module Git
59
61
  :commits_trailer_collaborator_capitalization_severity,
60
62
  :commits_trailer_collaborator_email_enabled,
61
63
  :commits_trailer_collaborator_email_severity,
64
+ :commits_trailer_collaborator_email_excludes,
62
65
  :commits_trailer_collaborator_key_enabled,
63
66
  :commits_trailer_collaborator_key_severity,
64
67
  :commits_trailer_collaborator_name_enabled,
@@ -78,6 +81,7 @@ module Git
78
81
  :commits_trailer_issue_value_includes,
79
82
  :commits_trailer_milestone_key_enabled,
80
83
  :commits_trailer_milestone_key_severity,
84
+ :commits_trailer_milestone_key_mandatory,
81
85
  :commits_trailer_milestone_value_enabled,
82
86
  :commits_trailer_milestone_value_severity,
83
87
  :commits_trailer_milestone_value_includes,
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.3.0
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -125,14 +125,14 @@ dependencies:
125
125
  requirements:
126
126
  - - "~>"
127
127
  - !ruby/object:Gem::Version
128
- version: '5.0'
128
+ version: '5.3'
129
129
  type: :runtime
130
130
  prerelease: false
131
131
  version_requirements: !ruby/object:Gem::Requirement
132
132
  requirements:
133
133
  - - "~>"
134
134
  - !ruby/object:Gem::Version
135
- version: '5.0'
135
+ version: '5.3'
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: infusible
138
138
  requirement: !ruby/object:Gem::Requirement
@@ -256,6 +256,7 @@ files:
256
256
  - lib/git/lint/analyzers/commit_body_leading_line.rb
257
257
  - lib/git/lint/analyzers/commit_body_line_length.rb
258
258
  - lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb
259
+ - lib/git/lint/analyzers/commit_body_paragraph_new_line.rb
259
260
  - lib/git/lint/analyzers/commit_body_phrase.rb
260
261
  - lib/git/lint/analyzers/commit_body_presence.rb
261
262
  - lib/git/lint/analyzers/commit_body_tracker_shorthand.rb
@@ -346,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
346
347
  - !ruby/object:Gem::Version
347
348
  version: '0'
348
349
  requirements: []
349
- rubygems_version: 4.0.12
350
+ rubygems_version: 4.0.13
350
351
  specification_version: 4
351
352
  summary: A command line interface for linting Git commits.
352
353
  test_files: []
metadata.gz.sig CHANGED
Binary file