git-lint 1.4.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.adoc +37 -139
  5. data/lib/git/lint.rb +18 -50
  6. data/lib/git/lint/analyzers/abstract.rb +12 -30
  7. data/lib/git/lint/analyzers/commit_author_capitalization.rb +1 -3
  8. data/lib/git/lint/analyzers/commit_author_email.rb +1 -3
  9. data/lib/git/lint/analyzers/commit_author_name.rb +2 -4
  10. data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -6
  11. data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +3 -9
  12. data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +4 -12
  13. data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +3 -9
  14. data/lib/git/lint/analyzers/commit_body_leading_line.rb +3 -3
  15. data/lib/git/lint/analyzers/commit_body_line_length.rb +3 -9
  16. data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +3 -9
  17. data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -6
  18. data/lib/git/lint/analyzers/commit_body_presence.rb +2 -4
  19. data/lib/git/lint/analyzers/commit_body_single_bullet.rb +3 -9
  20. data/lib/git/lint/analyzers/commit_subject_length.rb +2 -6
  21. data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -10
  22. data/lib/git/lint/analyzers/commit_subject_suffix.rb +1 -3
  23. data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +2 -4
  24. data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -5
  25. data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +2 -4
  26. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +3 -7
  27. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +3 -7
  28. data/lib/git/lint/branches/environments/circle_ci.rb +5 -9
  29. data/lib/git/lint/branches/environments/git_hub_action.rb +5 -9
  30. data/lib/git/lint/branches/environments/local.rb +5 -9
  31. data/lib/git/lint/branches/environments/netlify_ci.rb +9 -11
  32. data/lib/git/lint/branches/environments/travis_ci.rb +14 -22
  33. data/lib/git/lint/branches/feature.rb +6 -9
  34. data/lib/git/lint/cli.rb +10 -15
  35. data/lib/git/lint/collector.rb +12 -32
  36. data/lib/git/lint/identity.rb +1 -1
  37. data/lib/git/lint/kit/filter_list.rb +3 -9
  38. data/lib/git/lint/parsers/trailers/collaborator.rb +6 -14
  39. data/lib/git/lint/rake/tasks.rb +1 -3
  40. data/lib/git/lint/refinements/strings.rb +2 -6
  41. data/lib/git/lint/reporters/branch.rb +15 -15
  42. data/lib/git/lint/reporters/commit.rb +1 -3
  43. data/lib/git/lint/reporters/line.rb +1 -3
  44. data/lib/git/lint/reporters/lines/paragraph.rb +5 -15
  45. data/lib/git/lint/reporters/lines/sentence.rb +3 -9
  46. data/lib/git/lint/reporters/style.rb +1 -3
  47. data/lib/git/lint/runner.rb +5 -4
  48. data/lib/git/lint/validators/capitalization.rb +3 -7
  49. data/lib/git/lint/validators/email.rb +1 -3
  50. data/lib/git/lint/validators/name.rb +3 -7
  51. metadata +46 -21
  52. metadata.gz.sig +0 -0
  53. data/lib/git/kit/repo.rb +0 -30
  54. data/lib/git/lint/commits/saved.rb +0 -104
  55. data/lib/git/lint/commits/unsaved.rb +0 -120
@@ -9,9 +9,7 @@ module Git
9
9
  class Tasks
10
10
  include ::Rake::DSL
11
11
 
12
- def self.setup
13
- new.install
14
- end
12
+ def self.setup = new.install
15
13
 
16
14
  def initialize cli: CLI
17
15
  @cli = cli
@@ -11,13 +11,9 @@ module Git
11
11
  "#{count} #{self}#{suffix}"
12
12
  end
13
13
 
14
- def fixup?
15
- match?(/\Afixup!\s/)
16
- end
14
+ def fixup? = match?(/\Afixup!\s/)
17
15
 
18
- def squash?
19
- match?(/\Asquash!\s/)
20
- end
16
+ def squash? = match?(/\Asquash!\s/)
21
17
  end
22
18
  end
23
19
  end
@@ -7,7 +7,7 @@ module Git
7
7
  module Reporters
8
8
  # Reports issues related to a single branch.
9
9
  class Branch
10
- using Refinements::Strings
10
+ using GitPlus::Refinements::Strings
11
11
 
12
12
  def initialize collector: Collector.new, colorizer: Pastel.new
13
13
  @collector = collector
@@ -23,22 +23,30 @@ module Git
23
23
 
24
24
  attr_reader :collector, :colorizer
25
25
 
26
+ def branch_report
27
+ return "" unless collector.issues?
28
+
29
+ "\n\n#{commit_report}".chomp
30
+ end
31
+
26
32
  def commit_report
27
33
  collector.to_h.reduce "" do |details, (commit, analyzers)|
28
34
  details + Commit.new(commit: commit, analyzers: analyzers).to_s
29
35
  end
30
36
  end
31
37
 
32
- def branch_report
33
- return "" unless collector.issues?
34
-
35
- "\n\n#{commit_report}".chomp "\n"
36
- end
37
-
38
38
  def commit_total
39
39
  %(#{"commit".pluralize count: collector.total_commits} inspected)
40
40
  end
41
41
 
42
+ def issue_totals
43
+ if collector.issues?
44
+ "#{issue_total} detected (#{warning_total}, #{error_total})"
45
+ else
46
+ colorizer.green("0 issues") + " detected"
47
+ end
48
+ end
49
+
42
50
  def issue_total
43
51
  color = collector.errors? ? :red : :yellow
44
52
  colorizer.public_send color, "issue".pluralize(count: collector.total_issues)
@@ -53,14 +61,6 @@ module Git
53
61
  color = collector.errors? ? :red : :green
54
62
  colorizer.public_send color, "error".pluralize(count: collector.total_errors)
55
63
  end
56
-
57
- def issue_totals
58
- if collector.issues?
59
- "#{issue_total} detected (#{warning_total}, #{error_total})"
60
- else
61
- colorizer.green("0 issues") + " detected"
62
- end
63
- end
64
64
  end
65
65
  end
66
66
  end
@@ -21,9 +21,7 @@ module Git
21
21
 
22
22
  attr_reader :commit, :analyzers
23
23
 
24
- def report
25
- analyzers.reduce("") { |report, analyzer| report + Style.new(analyzer).to_s }
26
- end
24
+ def report = analyzers.reduce("") { |report, analyzer| report + Style.new(analyzer).to_s }
27
25
  end
28
26
  end
29
27
  end
@@ -23,9 +23,7 @@ module Git
23
23
 
24
24
  attr_reader :data
25
25
 
26
- def content
27
- data.fetch :content
28
- end
26
+ def content = data.fetch(__method__)
29
27
  end
30
28
  end
31
29
  end
@@ -17,13 +17,9 @@ module Git
17
17
 
18
18
  attr_reader :data
19
19
 
20
- def label
21
- "#{Line::DEFAULT_INDENT}Line #{number}: "
22
- end
20
+ def label = "#{Line::DEFAULT_INDENT}Line #{number}: "
23
21
 
24
- def paragraph
25
- formatted_lines.join "\n"
26
- end
22
+ def paragraph = formatted_lines.join("\n")
27
23
 
28
24
  def formatted_lines
29
25
  content.split("\n").map.with_index do |line, index|
@@ -31,17 +27,11 @@ module Git
31
27
  end
32
28
  end
33
29
 
34
- def indent
35
- " " * (label.length + 1)
36
- end
30
+ def indent = " " * (label.length + 1)
37
31
 
38
- def number
39
- data.fetch :number
40
- end
32
+ def number = data.fetch(:number)
41
33
 
42
- def content
43
- data.fetch :content
44
- end
34
+ def content = data.fetch(:content)
45
35
  end
46
36
  end
47
37
  end
@@ -9,21 +9,15 @@ module Git
9
9
  @data = data
10
10
  end
11
11
 
12
- def to_s
13
- %(#{Line::DEFAULT_INDENT}Line #{number}: "#{content}"\n)
14
- end
12
+ def to_s = %(#{Line::DEFAULT_INDENT}Line #{number}: "#{content}"\n)
15
13
 
16
14
  private
17
15
 
18
16
  attr_reader :data
19
17
 
20
- def number
21
- data.fetch :number
22
- end
18
+ def number = data.fetch(:number)
23
19
 
24
- def content
25
- data.fetch :content
26
- end
20
+ def content = data.fetch(:content)
27
21
  end
28
22
  end
29
23
  end
@@ -13,9 +13,7 @@ module Git
13
13
  @colorizer = colorizer
14
14
  end
15
15
 
16
- def to_s
17
- colorizer.public_send color, message
18
- end
16
+ def to_s = colorizer.public_send(color, message)
19
17
 
20
18
  private
21
19
 
@@ -3,19 +3,20 @@
3
3
  module Git
4
4
  module Lint
5
5
  class Runner
6
- def initialize configuration:, collector: Collector.new
6
+ def initialize configuration:, branch: Branches::Feature.new, collector: Collector.new
7
7
  @configuration = configuration
8
+ @branch = branch
8
9
  @collector = collector
9
10
  end
10
11
 
11
- def call commits: Branches::Feature.new.commits
12
- Array(commits).map { |commit| check commit }
12
+ def call commits: branch.commits
13
+ commits.map { |commit| check commit }
13
14
  collector
14
15
  end
15
16
 
16
17
  private
17
18
 
18
- attr_reader :configuration, :collector
19
+ attr_reader :configuration, :branch, :collector
19
20
 
20
21
  def check commit
21
22
  configuration.map { |id, settings| load_analyzer id, commit, settings }
@@ -4,7 +4,7 @@ module Git
4
4
  module Lint
5
5
  module Validators
6
6
  class Capitalization
7
- DEFAULT_PATTERN = /\A[[:upper:]].*\Z/.freeze
7
+ DEFAULT_PATTERN = /\A[[:upper:]].*\Z/
8
8
 
9
9
  def initialize text, delimiter: Name::DEFAULT_DELIMITER, pattern: DEFAULT_PATTERN
10
10
  @text = String text
@@ -12,17 +12,13 @@ module Git
12
12
  @pattern = pattern
13
13
  end
14
14
 
15
- def valid?
16
- parts.all? { |name| String(name).match? pattern }
17
- end
15
+ def valid? = parts.all? { |name| String(name).match? pattern }
18
16
 
19
17
  private
20
18
 
21
19
  attr_reader :text, :delimiter, :pattern
22
20
 
23
- def parts
24
- text.split delimiter
25
- end
21
+ def parts = text.split(delimiter)
26
22
  end
27
23
  end
28
24
  end
@@ -11,9 +11,7 @@ module Git
11
11
  @pattern = pattern
12
12
  end
13
13
 
14
- def valid?
15
- String(text).match? pattern
16
- end
14
+ def valid? = String(text).match?(pattern)
17
15
 
18
16
  private
19
17
 
@@ -4,7 +4,7 @@ module Git
4
4
  module Lint
5
5
  module Validators
6
6
  class Name
7
- DEFAULT_DELIMITER = /\s{1}/.freeze
7
+ DEFAULT_DELIMITER = /\s{1}/
8
8
  DEFAULT_MINIMUM = 2
9
9
 
10
10
  def initialize text, delimiter: DEFAULT_DELIMITER, minimum: DEFAULT_MINIMUM
@@ -13,17 +13,13 @@ module Git
13
13
  @minimum = minimum
14
14
  end
15
15
 
16
- def valid?
17
- parts.size >= minimum && parts.all? { |name| !String(name).empty? }
18
- end
16
+ def valid? = parts.size >= minimum && parts.all? { |name| !String(name).empty? }
19
17
 
20
18
  private
21
19
 
22
20
  attr_reader :text, :delimiter, :minimum
23
21
 
24
- def parts
25
- String(text).split delimiter
26
- end
22
+ def parts = String(text).split(delimiter)
27
23
  end
28
24
  end
29
25
  end
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: 1.4.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
- a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
15
- NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
13
+ MIIC/jCCAeagAwIBAgIBBDANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
+ a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMTAzMTkxMjQ4MDZaFw0yMjAzMTkx
15
+ MjQ4MDZaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
16
16
  IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
17
17
  xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
18
18
  brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
@@ -20,16 +20,30 @@ cert_chain:
20
20
  D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
21
21
  3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
22
22
  AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
23
- 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
24
- XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
25
- bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
26
- Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
27
- 7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
28
- 2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
- QWc=
23
+ 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAEjpaOXHHp8s/7GL2qCb
24
+ YAs7urOLv9VHSPfQWAwaTMVnSsIf3Sw4xzISOP/mmfEPBPXtz61K5esrE/uTFtgb
25
+ FyjxQk2H0sEWgrRXGGNHBWQRhhEs7LP/TByoC15A0br++xLxRz4r7HBLGAWQQDpg
26
+ 66BJ2TBVjxS6K64tKbq7+ACyrOZGgTfNHACh4M076y0x0oRf/rwBrU39/KRfuhbb
27
+ cm+nNCEtO35gTmZ2bVDHLGvWazi3gJt6+huQjfXTCUUG2YYBxwhu+GPdAGQPxpf9
28
+ lkHilIrX69jq8wMPpBhlaw2mRmeSL50Wv5u6xVBvOHhXFSP1crXM95vfLhLyRYod
29
+ W2A=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-12-13 00:00:00.000000000 Z
31
+ date: 2021-07-05 00:00:00.000000000 Z
32
32
  dependencies:
33
+ - !ruby/object:Gem::Dependency
34
+ name: git_plus
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.5'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.5'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: pastel
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -50,28 +64,28 @@ dependencies:
50
64
  requirements:
51
65
  - - "~>"
52
66
  - !ruby/object:Gem::Version
53
- version: '7.16'
67
+ version: '8.0'
54
68
  type: :runtime
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - "~>"
59
73
  - !ruby/object:Gem::Version
60
- version: '7.16'
74
+ version: '8.0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: runcom
63
77
  requirement: !ruby/object:Gem::Requirement
64
78
  requirements:
65
79
  - - "~>"
66
80
  - !ruby/object:Gem::Version
67
- version: '6.4'
81
+ version: '7.0'
68
82
  type: :runtime
69
83
  prerelease: false
70
84
  version_requirements: !ruby/object:Gem::Requirement
71
85
  requirements:
72
86
  - - "~>"
73
87
  - !ruby/object:Gem::Version
74
- version: '6.4'
88
+ version: '7.0'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: thor
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +100,20 @@ dependencies:
86
100
  - - "~>"
87
101
  - !ruby/object:Gem::Version
88
102
  version: '0.20'
103
+ - !ruby/object:Gem::Dependency
104
+ name: zeitwerk
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '2.4'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.4'
89
117
  description:
90
118
  email:
91
119
  - brooke@alchemists.io
@@ -99,7 +127,6 @@ files:
99
127
  - LICENSE.adoc
100
128
  - README.adoc
101
129
  - bin/git-lint
102
- - lib/git/kit/repo.rb
103
130
  - lib/git/lint.rb
104
131
  - lib/git/lint/analyzers/abstract.rb
105
132
  - lib/git/lint/analyzers/commit_author_capitalization.rb
@@ -131,8 +158,6 @@ files:
131
158
  - lib/git/lint/branches/feature.rb
132
159
  - lib/git/lint/cli.rb
133
160
  - lib/git/lint/collector.rb
134
- - lib/git/lint/commits/saved.rb
135
- - lib/git/lint/commits/unsaved.rb
136
161
  - lib/git/lint/errors/base.rb
137
162
  - lib/git/lint/errors/severity.rb
138
163
  - lib/git/lint/errors/sha.rb
@@ -168,14 +193,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
193
  requirements:
169
194
  - - "~>"
170
195
  - !ruby/object:Gem::Version
171
- version: '2.7'
196
+ version: '3.0'
172
197
  required_rubygems_version: !ruby/object:Gem::Requirement
173
198
  requirements:
174
199
  - - ">="
175
200
  - !ruby/object:Gem::Version
176
201
  version: '0'
177
202
  requirements: []
178
- rubygems_version: 3.2.0
203
+ rubygems_version: 3.2.21
179
204
  signing_key:
180
205
  specification_version: 4
181
206
  summary: A command line interface for linting Git commits.
metadata.gz.sig CHANGED
Binary file
data/lib/git/kit/repo.rb DELETED
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Git
4
- module Kit
5
- class Repo
6
- def initialize shell: Open3
7
- @shell = shell
8
- end
9
-
10
- def exist?
11
- shell.capture2e("git rev-parse --git-dir > /dev/null 2>&1")
12
- .then { |result, status| result && status.success? }
13
- end
14
-
15
- def branch_name
16
- shell.capture2e("git rev-parse --abbrev-ref HEAD | tr -d '\n'")
17
- .then { |result, _status| result }
18
- end
19
-
20
- def shas start: "master", finish: branch_name
21
- shell.capture2e(%(git log --pretty=format:"%H" #{start}..#{finish}))
22
- .then { |result, _status| result.split "\n" }
23
- end
24
-
25
- private
26
-
27
- attr_reader :shell
28
- end
29
- end
30
- end