git-lint 2.3.3 → 3.0.2

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 (75) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/LICENSE.adoc +207 -155
  4. data/README.adoc +203 -222
  5. data/{bin → exe}/git-lint +1 -3
  6. data/lib/git/lint/analyzer.rb +76 -0
  7. data/lib/git/lint/analyzers/abstract.rb +8 -18
  8. data/lib/git/lint/analyzers/commit_author_capitalization.rb +3 -9
  9. data/lib/git/lint/analyzers/commit_author_email.rb +3 -9
  10. data/lib/git/lint/analyzers/commit_author_name.rb +5 -14
  11. data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -9
  12. data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +2 -9
  13. data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +2 -9
  14. data/lib/git/lint/analyzers/commit_body_leading_line.rb +1 -7
  15. data/lib/git/lint/analyzers/commit_body_line_length.rb +4 -11
  16. data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +1 -7
  17. data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -38
  18. data/lib/git/lint/analyzers/commit_body_presence.rb +5 -12
  19. data/lib/git/lint/analyzers/commit_body_single_bullet.rb +2 -9
  20. data/lib/git/lint/analyzers/commit_body_tracker_shorthand.rb +27 -0
  21. data/lib/git/lint/analyzers/commit_subject_length.rb +4 -11
  22. data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -9
  23. data/lib/git/lint/analyzers/commit_subject_suffix.rb +2 -13
  24. data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +3 -12
  25. data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -11
  26. data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +3 -12
  27. data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +4 -13
  28. data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +5 -15
  29. data/lib/git/lint/cli/actions/analyze/branch.rb +43 -0
  30. data/lib/git/lint/cli/actions/analyze/commit.rb +44 -0
  31. data/lib/git/lint/cli/actions/config.rb +37 -0
  32. data/lib/git/lint/cli/actions/hook.rb +34 -0
  33. data/lib/git/lint/cli/parser.rb +33 -0
  34. data/lib/git/lint/cli/parsers/analyze.rb +40 -0
  35. data/lib/git/lint/cli/parsers/core.rb +72 -0
  36. data/lib/git/lint/cli/shell.rb +56 -0
  37. data/lib/git/lint/collector.rb +3 -4
  38. data/lib/git/lint/commits/container.rb +19 -0
  39. data/lib/git/lint/commits/loader.rb +51 -0
  40. data/lib/git/lint/commits/systems/circle_ci.rb +26 -0
  41. data/lib/git/lint/{branches/environments → commits/systems}/git_hub_action.rb +10 -8
  42. data/lib/git/lint/commits/systems/local.rb +26 -0
  43. data/lib/git/lint/{branches/environments → commits/systems}/netlify_ci.rb +14 -10
  44. data/lib/git/lint/configuration/content.rb +26 -0
  45. data/lib/git/lint/configuration/defaults.yml +118 -0
  46. data/lib/git/lint/configuration/loader.rb +50 -0
  47. data/lib/git/lint/configuration/setting.rb +24 -0
  48. data/lib/git/lint/container.rb +41 -0
  49. data/lib/git/lint/errors/severity.rb +1 -0
  50. data/lib/git/lint/errors/sha.rb +1 -0
  51. data/lib/git/lint/identity.rb +2 -1
  52. data/lib/git/lint/kit/filter_list.rb +1 -1
  53. data/lib/git/lint/parsers/trailers/collaborator.rb +1 -0
  54. data/lib/git/lint/rake/tasks.rb +5 -4
  55. data/lib/git/lint/reporters/branch.rb +12 -6
  56. data/lib/git/lint/reporters/commit.rb +3 -1
  57. data/lib/git/lint/reporters/line.rb +3 -5
  58. data/lib/git/lint/reporters/lines/paragraph.rb +3 -0
  59. data/lib/git/lint/reporters/lines/sentence.rb +3 -0
  60. data/lib/git/lint/reporters/style.rb +3 -1
  61. data/lib/git/lint/validators/capitalization.rb +1 -0
  62. data/lib/git/lint/validators/email.rb +1 -0
  63. data/lib/git/lint/validators/name.rb +1 -0
  64. data/lib/git/lint.rb +18 -47
  65. data.tar.gz.sig +0 -0
  66. metadata +55 -29
  67. metadata.gz.sig +0 -0
  68. data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +0 -39
  69. data/lib/git/lint/branches/environments/circle_ci.rb +0 -24
  70. data/lib/git/lint/branches/environments/local.rb +0 -24
  71. data/lib/git/lint/branches/environments/travis_ci.rb +0 -49
  72. data/lib/git/lint/branches/feature.rb +0 -42
  73. data/lib/git/lint/cli.rb +0 -117
  74. data/lib/git/lint/refinements/strings.rb +0 -21
  75. data/lib/git/lint/runner.rb +0 -35
data/README.adoc CHANGED
@@ -12,9 +12,6 @@ image::https://badge.fury.io/rb/git-lint.svg[Gem Version]
12
12
  image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
13
13
  [link=https://circleci.com/gh/bkuhlmann/git-lint]
14
14
  image::https://circleci.com/gh/bkuhlmann/git-lint.svg?style=svg[Circle CI Status]
15
-
16
- [link=https://travis-ci.org/bkuhlmann/git-lint]
17
- image::https://travis-ci.org/bkuhlmann/git-lint.svg?branch=main[Travis CI Status]
18
15
  [link=https://app.netlify.com/sites/git-lint/deploys]
19
16
  image::https://api.netlify.com/api/v1/badges/7e23b422-3412-4e7f-b654-65c0417a0b1f/deploy-status[Netlify CI Status]
20
17
 
@@ -35,11 +32,6 @@ toc::[]
35
32
  * Provides Git Hook support for local use.
36
33
  * Provides Continuous Integration (CI) support.
37
34
 
38
- == Screencasts
39
-
40
- [link=https://www.alchemists.io/screencasts/git_lint]
41
- image::https://www.alchemists.io/images/screencasts/git_lint/cover.svg[Screencast,600,240,role=focal_point]
42
-
43
35
  == Requirements
44
36
 
45
37
  . link:https://www.ruby-lang.org[Ruby]
@@ -53,6 +45,23 @@ To install, run:
53
45
  gem install git-lint
54
46
  ----
55
47
 
48
+ == Upgrade
49
+
50
+ If upgrading from 2.0.0 to 3.0.0, you'll need to make the following changes:
51
+
52
+ * The YAML configuration requires a top-level `:analyzers:` key for which all analyzer
53
+ configurations should be listed under. See the _Configuration_ section below for more details.
54
+ * The `--config` command requires either an `edit` or `view` argument now.
55
+ * The `--analyze` command can accept a `--sha` option for passing in the hash of the SHA you want to
56
+ analyze. If using this as a post commit Git Hook, you'll need to update your Bash script
57
+ accordingly.
58
+ * The _Commit Body Line Length_ analyzer configuration has replaced `length` with `maximum` as the
59
+ key for defining maximum line length.
60
+ * The _Commit Body Issue Tracker Link_ analyzer has been replaced with the _Commit Body Tracker
61
+ Shorthand_ analyzer. See documentation below for details.
62
+ * The _Commit Subject Length_ analyzer has replaced `length` with `maximum` as the key for defining
63
+ maximum subject length.
64
+
56
65
  == Usage
57
66
 
58
67
  === Command Line Interface (CLI)
@@ -60,11 +69,15 @@ gem install git-lint
60
69
  From the command line, type: `git-lint --help`
61
70
 
62
71
  ....
63
- git-lint --hook # Add Git Hook support.
64
- git-lint -a, [--analyze] # Analyze feature branch for issues.
65
- git-lint -c, [--config] # Manage gem configuration.
66
- git-lint -h, [--help=COMMAND] # Show this message or get help for a command.
67
- git-lint -v, [--version] # Show gem version.
72
+ USAGE:
73
+ -a, --analyze [options] Analyze current branch commits.
74
+ -c, --config ACTION Manage gem configuration. Actions: edit or view.
75
+ -h, --help Show this message.
76
+ --hook PATH Hook for analyzing unsaved commits.
77
+ -v, --version Show gem version.
78
+
79
+ ANALYZE OPTIONS:
80
+ --sha HASH Analyze specific commit SHA.
68
81
  ....
69
82
 
70
83
  To check if your Git commit history is clean, run: `git-lint --analyze`. It will exit with a failure
@@ -112,7 +125,8 @@ require "git/lint/rake/setup"
112
125
 
113
126
  Now, when running `bundle exec rake -T`, you'll see `git_lint` included in the list.
114
127
 
115
- If you need a concrete example, check out the link:Rakefile[Rakefile] of this project for details.
128
+ If you need a concrete example, check out the
129
+ link:https://github.com/bkuhlmann/git-lint/blob/main/Rakefile[Rakefile] of this project for details.
116
130
 
117
131
  === Default Branch
118
132
 
@@ -142,124 +156,124 @@ variables. The default configuration is:
142
156
 
143
157
  [source,yaml]
144
158
  ----
145
- :commit_author_capitalization:
146
- :enabled: true
147
- :severity: :error
148
- :commit_author_email:
149
- :enabled: true
150
- :severity: :error
151
- :commit_author_name:
152
- :enabled: true
153
- :severity: :error
154
- :minimum: 2
155
- :commit_body_bullet:
156
- :enabled: true
157
- :severity: :error
158
- :excludes:
159
- - "\\*"
160
- - ""
161
- :commit_body_bullet_capitalization:
162
- :enabled: true
163
- :severity: :error
164
- :includes: "\\-"
165
- :commit_body_bullet_delimiter:
166
- :enabled: true
167
- :severity: :error
168
- :includes: "\\-"
169
- :commit_body_issue_tracker_link:
170
- :enabled: true
171
- :severity: :error
172
- :excludes:
173
- - "(f|F)ix(es|ed)?\\s\\#\\d+"
174
- - "(c|C)lose(s|d)?\\s\\#\\d+"
175
- - "(r|R)esolve(s|d)?\\s\\#\\d+"
176
- - "github\\.com\\/.+\\/issues\\/\\d+"
177
- :commit_body_leading_line:
178
- :enabled: false
179
- :severity: :warn
180
- :commit_body_line_length:
181
- :enabled: true
182
- :severity: :error
183
- :length: 72
184
- :commit_body_paragraph_capitalization:
185
- :enabled: true
186
- :severity: :error
187
- :commit_body_phrase:
188
- :enabled: true
189
- :severity: :error
190
- :excludes:
191
- - "absolutely"
192
- - "actually"
193
- - "all intents and purposes"
194
- - "along the lines"
195
- - "at this moment in time"
196
- - "basically"
197
- - "each and every one"
198
- - "everyone knows"
199
- - "fact of the matter"
200
- - "furthermore"
201
- - "however"
202
- - "in due course"
203
- - "in the end"
204
- - "last but not least"
205
- - "matter of fact"
206
- - "obviously"
207
- - "of course"
208
- - "really"
209
- - "simply"
210
- - "things being equal"
211
- - "would like to"
212
- - "/\\beasy\\b/"
213
- - "/\\bjust\\b/"
214
- - "/\\bquite\\b/"
215
- - "/as\\sfar\\sas\\s.+\\sconcerned/"
216
- - "/of\\sthe\\s(fact|opinion)\\sthat/"
217
- :commit_body_presence:
218
- :enabled: false
219
- :severity: :warn
220
- :minimum: 1
221
- :commit_body_single_bullet:
222
- :enabled: true
223
- :severity: :error
224
- :includes: "\\-"
225
- :commit_subject_length:
226
- :enabled: true
227
- :severity: :error
228
- :length: 72
229
- :commit_subject_prefix:
230
- :enabled: true
231
- :severity: :error
232
- :includes:
233
- - Fixed
234
- - Added
235
- - Updated
236
- - Removed
237
- - Refactored
238
- :commit_subject_suffix:
239
- :enabled: true
240
- :severity: :error
241
- :excludes:
242
- - "\\."
243
- - "\\?"
244
- - "\\!"
245
- :commit_trailer_collaborator_capitalization:
246
- :enabled: true
247
- :severity: :error
248
- :commit_trailer_collaborator_duplication:
249
- :enabled: true
250
- :severity: :error
251
- :commit_trailer_collaborator_email:
252
- :enabled: true
253
- :severity: :error
254
- :commit_trailer_collaborator_key:
255
- :enabled: true
256
- :severity: :error
257
- :includes:
258
- - "Co-Authored-By"
259
- :commit_trailer_collaborator_name:
260
- :enabled: true
261
- :severity: :error
262
- :minimum: 2
159
+ :analyzers:
160
+ :commit_author_capitalization:
161
+ :enabled: true
162
+ :severity: :error
163
+ :commit_author_email:
164
+ :enabled: true
165
+ :severity: :error
166
+ :commit_author_name:
167
+ :enabled: true
168
+ :severity: :error
169
+ :minimum: 2
170
+ :commit_body_bullet:
171
+ :enabled: true
172
+ :severity: :error
173
+ :excludes:
174
+ - "\\*"
175
+ - "•"
176
+ :commit_body_bullet_capitalization:
177
+ :enabled: true
178
+ :severity: :error
179
+ :includes: "\\-"
180
+ :commit_body_bullet_delimiter:
181
+ :enabled: true
182
+ :severity: :error
183
+ :includes: "\\-"
184
+ :commit_body_tracker_shorthand:
185
+ :enabled: true
186
+ :severity: :error
187
+ :excludes:
188
+ - "(f|F)ix(es|ed)?\\s\\#\\d+"
189
+ - "(c|C)lose(s|d)?\\s\\#\\d+"
190
+ - "(r|R)esolve(s|d)?\\s\\#\\d+"
191
+ :commit_body_leading_line:
192
+ :enabled: false
193
+ :severity: :warn
194
+ :commit_body_line_length:
195
+ :enabled: true
196
+ :severity: :error
197
+ :maximum: 72
198
+ :commit_body_paragraph_capitalization:
199
+ :enabled: true
200
+ :severity: :error
201
+ :commit_body_phrase:
202
+ :enabled: true
203
+ :severity: :error
204
+ :excludes:
205
+ - "absolutely"
206
+ - "actually"
207
+ - "all intents and purposes"
208
+ - "along the lines"
209
+ - "at this moment in time"
210
+ - "basically"
211
+ - "each and every one"
212
+ - "everyone knows"
213
+ - "fact of the matter"
214
+ - "furthermore"
215
+ - "however"
216
+ - "in due course"
217
+ - "in the end"
218
+ - "last but not least"
219
+ - "matter of fact"
220
+ - "obviously"
221
+ - "of course"
222
+ - "really"
223
+ - "simply"
224
+ - "things being equal"
225
+ - "would like to"
226
+ - "\\beasy\\b"
227
+ - "\\bjust\\b"
228
+ - "\\bquite\\b"
229
+ - "as\\sfar\\sas\\s.+\\sconcerned"
230
+ - "of\\sthe\\s(fact|opinion)\\sthat"
231
+ :commit_body_presence:
232
+ :enabled: false
233
+ :severity: :warn
234
+ :minimum: 1
235
+ :commit_body_single_bullet:
236
+ :enabled: true
237
+ :severity: :error
238
+ :includes: "\\-"
239
+ :commit_subject_length:
240
+ :enabled: true
241
+ :severity: :error
242
+ :maximum: 72
243
+ :commit_subject_prefix:
244
+ :enabled: true
245
+ :severity: :error
246
+ :includes:
247
+ - Fixed
248
+ - Added
249
+ - Updated
250
+ - Removed
251
+ - Refactored
252
+ :commit_subject_suffix:
253
+ :enabled: true
254
+ :severity: :error
255
+ :excludes:
256
+ - "\\."
257
+ - "\\?"
258
+ - "\\!"
259
+ :commit_trailer_collaborator_capitalization:
260
+ :enabled: true
261
+ :severity: :error
262
+ :commit_trailer_collaborator_duplication:
263
+ :enabled: true
264
+ :severity: :error
265
+ :commit_trailer_collaborator_email:
266
+ :enabled: true
267
+ :severity: :error
268
+ :commit_trailer_collaborator_key:
269
+ :enabled: true
270
+ :severity: :error
271
+ :includes:
272
+ - "Co-Authored-By"
273
+ :commit_trailer_collaborator_name:
274
+ :enabled: true
275
+ :severity: :error
276
+ :minimum: 2
263
277
  ----
264
278
 
265
279
  Feel free to take this default configuration, modify, and save as your own custom
@@ -315,18 +329,15 @@ any of the scripts within the `.git/hooks` directory of the repository.
315
329
 
316
330
  ==== Commit Message
317
331
 
318
- The _commit-msg_ hook, which is the best way to use this gem as a Git Hook, is provided as a
319
- `--hook` option. Run `git-lint --help --hook` for usage:
332
+ The _commit-msg_ hook -- which is the best way to use this gem as a Git Hook -- is provided as a
333
+ `--hook` option. Usage:
320
334
 
321
- Usage:
322
- git-lint --hook
323
-
324
- Options:
325
- [--commit-message=PATH] # Check commit message.
326
-
327
- Add Git Hook support.
335
+ [source,bash]
336
+ ----
337
+ git-lint --hook PATH
338
+ ----
328
339
 
329
- As shown above, the `--commit-message` option accepts a file path (i.e. `.git/COMMIT_EDITMSG`) which
340
+ As shown above, the `--hook` command accepts a file path (i.e. `.git/COMMIT_EDITMSG`) which
330
341
  is provided to you by Git within the `.git/hooks/commit-msg` script. Here is a working example of
331
342
  what that script might look like:
332
343
 
@@ -344,27 +355,22 @@ if ! command -v git-lint > /dev/null; then
344
355
  exit 1
345
356
  fi
346
357
 
347
- git-lint --hook --commit-message "${BASH_ARGV[0]}"
358
+ git-lint --hook "${BASH_ARGV[0]}"
348
359
  ----
349
360
 
350
361
  Whenever you attempt to add a commit, Git Lint will check your commit for issues prior to saving it.
351
362
 
352
363
  ==== Post Commit
353
364
 
354
- The _post-commit_ hook is possible via the `--analyze --commits` option. Usage:
355
-
356
- ....
357
- Usage:
358
- git-lint -a, [--analyze]
359
-
360
- Options:
361
- -c, [--commits=one two three] # Analyze specific commit SHA(s).
365
+ The _post-commit_ hook is possible via the `--analyze` command. Usage:
362
366
 
363
- Analyze feature branch for issues.
364
- ....
367
+ [source,bash]
368
+ ----
369
+ git-lint --analyze --shas SHA
370
+ ----
365
371
 
366
- The _post-commit_ hook can be used multiple ways but, if you want it to check each commit after it
367
- has been made, here is a working example which can be used as a `.git/hooks/post-commit` script:
372
+ The _post-commit_ hook can be used multiple ways but, generally, you'll want to check the last
373
+ commit made. Here is a working example which can be used as a `.git/hooks/post-commit` script:
368
374
 
369
375
  [source,bash]
370
376
  ----
@@ -380,7 +386,7 @@ if ! command -v git-lint > /dev/null; then
380
386
  exit 1
381
387
  fi
382
388
 
383
- git-lint --analyze --commits $(git log --pretty=format:%H -1)
389
+ git-lint --analyze --shas $(git log --pretty=format:%H -1)
384
390
  ----
385
391
 
386
392
  Whenever a commit has been saved, this script will run Git Lint to check for issues.
@@ -434,11 +440,6 @@ The above will ensure Git Lint runs as an additional check on each Pull Request.
434
440
  Detection and configuration happens automatically by checking the `NETLIFY` environment variable. No
435
441
  additional setup required!
436
442
 
437
- ==== link:https://travis-ci.org[Travis CI]
438
-
439
- Detection and configuration happens automatically by checking the `TRAVIS` environment variable. No
440
- additional setup required!
441
-
442
443
  == Analyzers
443
444
 
444
445
  The following details the various analyzers provided by this gem to ensure a high standard of
@@ -557,38 +558,6 @@ Ensures commit body bullets are delimited by a space. Example:
557
558
  - An example bullet.
558
559
  ....
559
560
 
560
- === Commit Body Issue Tracker Link
561
-
562
- [options="header"]
563
- |===
564
- | Enabled | Severity | Defaults
565
- | true | error | excludes: (see configuration)
566
- |===
567
-
568
- Ensures commit body doesn't contain a link to an issue tracker. The exclude list defaults to GitHub
569
- Issue links but can be customized for any issue tracker.
570
-
571
- There are several reasons for excluding issue tracker links from commit bodies:
572
-
573
- . Not all issue trackers preserve issues (meaning they can be deleted). This makes make reading
574
- historic commits much harder to understand why the change was made when the link no longer works.
575
- . When not connected to the internet or working on a laggy connection, it's hard to understand why
576
- a commit was made when all you have is a link to an issue with no other supporting context.
577
- . During the course of a repository's life, issue trackers can be replaced (rare but it does
578
- happen). If the old issue tracker service is no longer paid for, none of the links within the
579
- commit will be of any relevance.
580
- . An issue might span several commits in order to resolve it. Including a link in each commit is
581
- tedious and can create noise within the issue's history which is distracting.
582
-
583
- Instead of linking to issues, take the time to write a short summary as to _why_ the commit was
584
- made. Doing this will make it easier to understand _why_ the commit was made, keeps the commit self-
585
- contained, and makes learning about/debugging the commit faster.
586
-
587
- Issue tracker links are best used at the code review level due to an issue usually spanning multiple
588
- commits in order to complete the work. When reading a code review, this is a great opportunity to
589
- link to an issue in order to provide a high level overview and reason why the code review was
590
- initiated in the first place.
591
-
592
561
  === Commit Body Leading Line
593
562
 
594
563
  [options="header"]
@@ -625,13 +594,12 @@ ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, orn
625
594
  [options="header"]
626
595
  |===
627
596
  | Enabled | Severity | Defaults
628
- | true | error | length: 72
597
+ | true | error | maximum: 72
629
598
  |===
630
599
 
631
- Ensures each line of the commit body is no longer than 72 characters in length for consistent
632
- readability and word-wrap prevention on smaller screen sizes. For further details, read Tim Pope's
633
- original link:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[article] on the
634
- subject.
600
+ Ensures each line of the commit body doesn't force you to scroll horizontally to read the message.
601
+ This allows commit messages to remain readable and is especially handy when commit messages are read
602
+ via the command line or email clients.
635
603
 
636
604
  === Commit Body Paragraph Capitalization
637
605
 
@@ -711,12 +679,37 @@ Pellentque morbi-trist sentus et netus et malesuada fames ac turpis egestas. Ves
711
679
  quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu_libero sit amet quam.
712
680
  ....
713
681
 
682
+ === Commit Body Tracker Shorthand
683
+
684
+ [options="header"]
685
+ |===
686
+ | Enabled | Severity | Defaults
687
+ | true | error | excludes: (see configuration)
688
+ |===
689
+
690
+ Ensures commit body doesn't use issue tracker shorthand. The exclude list defaults to GitHub Issues
691
+ but can be customized for any issue tracker.
692
+
693
+ There are several reasons for excluding issue tracker links from commit bodies:
694
+
695
+ . Not all issue trackers preserve issues (meaning they can be deleted). This makes make reading
696
+ historic commits harder to understand why the change was made when the reference no longer works.
697
+ . When disconnected from the internet or working on a laggy connection, it's hard to understand why
698
+ a commit was made when all you have is a shorthand issue reference with no supporting context.
699
+ . During the course of a repository's life, issue trackers can be replaced (rare but does happen).
700
+ If the old issue tracker service is no longer in use, none of the commit body shorthand will
701
+ be of any relevance.
702
+
703
+ Instead of using tracker shorthand syntax, take the time to write a short summary as to _why_ the
704
+ commit was made. Doing this will make it easier to understand _why_ the commit was made, keeps the
705
+ commit self-contained, and makes learning about/debugging the commit faster.
706
+
714
707
  === Commit Subject Length
715
708
 
716
709
  [options="header"]
717
710
  |===
718
711
  | Enabled | Severity | Defaults
719
- | true | error | length: 72
712
+ | true | error | maximum: 72
720
713
  |===
721
714
 
722
715
  Ensures the commit subject length is no more than 72 characters in length. This default is more
@@ -905,9 +898,9 @@ worth considering:
905
898
  Submodules can accomplish.
906
899
  * Avoid using link:https://git-lfs.github.com[Git LFS] for tracking binary artifacts/resources.
907
900
  These files are not meant for version control and lead to large repositories that are time
908
- consuming to clone/deploy. Use storage managers, like link:https://aws.amazon.com/s3[Amazon S3] or
909
- link:https://lakefs.io[LakeFS] for example, that are better suited for binary assets that don't
910
- change often.
901
+ consuming to clone/deploy. Use storage managers like link:https://git-annex.branchable.com[Git
902
+ Annex], link:https://aws.amazon.com/s3[Amazon S3], or link:https://lakefs.io[LakeFS] which are
903
+ better suited for binary assets that don't change often.
911
904
 
912
905
  === Security
913
906
 
@@ -1012,31 +1005,19 @@ To test, run:
1012
1005
  bundle exec rake
1013
1006
  ----
1014
1007
 
1015
- == Versioning
1016
-
1017
- Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
1018
-
1019
- * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
1020
- * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
1021
- * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
1022
-
1023
- == Code of Conduct
1024
-
1025
- Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
1026
- participating in this project you agree to abide by its terms.
1027
-
1028
- == Contributions
1008
+ == link:https://www.alchemists.io/policies/license[License]
1029
1009
 
1030
- Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
1010
+ == link:https://www.alchemists.io/policies/security[Security]
1031
1011
 
1032
- == License
1012
+ == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
1033
1013
 
1034
- Read link:LICENSE.adoc[LICENSE] for details.
1014
+ == link:https://www.alchemists.io/policies/contributions[Contributions]
1035
1015
 
1036
- == History
1016
+ == link:https://www.alchemists.io/projects/git-lint/versions[Versions]
1037
1017
 
1038
- Read link:CHANGES.adoc[CHANGES] for details.
1018
+ == link:https://www.alchemists.io/community[Community]
1039
1019
 
1040
1020
  == Credits
1041
1021
 
1042
- Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
1022
+ * Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
1023
+ * Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
@@ -2,8 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "git/lint"
5
- require "git/lint/cli"
6
- require "git/lint/identity"
7
5
 
8
6
  Process.setproctitle Git::Lint::Identity::VERSION_LABEL
9
- Git::Lint::CLI.start
7
+ Git::Lint::CLI::Shell.new.call ARGV
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Git
4
+ module Lint
5
+ # Runs all analyzers.
6
+ class Analyzer
7
+ ANALYZERS = [
8
+ Analyzers::CommitAuthorCapitalization,
9
+ Analyzers::CommitAuthorEmail,
10
+ Analyzers::CommitAuthorName,
11
+ Analyzers::CommitBodyBullet,
12
+ Analyzers::CommitBodyBulletCapitalization,
13
+ Analyzers::CommitBodyBulletDelimiter,
14
+ Analyzers::CommitBodyLeadingLine,
15
+ Analyzers::CommitBodyLineLength,
16
+ Analyzers::CommitBodyParagraphCapitalization,
17
+ Analyzers::CommitBodyPhrase,
18
+ Analyzers::CommitBodyPresence,
19
+ Analyzers::CommitBodySingleBullet,
20
+ Analyzers::CommitBodyTrackerShorthand,
21
+ Analyzers::CommitSubjectLength,
22
+ Analyzers::CommitSubjectPrefix,
23
+ Analyzers::CommitSubjectSuffix,
24
+ Analyzers::CommitTrailerCollaboratorCapitalization,
25
+ Analyzers::CommitTrailerCollaboratorDuplication,
26
+ Analyzers::CommitTrailerCollaboratorEmail,
27
+ Analyzers::CommitTrailerCollaboratorKey,
28
+ Analyzers::CommitTrailerCollaboratorName
29
+ ].freeze
30
+
31
+ # rubocop:disable Metrics/ParameterLists
32
+ def initialize analyzers: ANALYZERS,
33
+ collector: Collector.new,
34
+ reporter: Reporters::Branch,
35
+ container: Container
36
+ @analyzers = analyzers
37
+ @collector = collector
38
+ @reporter = reporter
39
+ @container = container
40
+ end
41
+ # rubocop:enable Metrics/ParameterLists
42
+
43
+ def call commits: Commits::Loader.new.call
44
+ process commits
45
+ a_reporter = reporter.new(collector:)
46
+ block_given? ? yield(collector, a_reporter) : [collector, a_reporter]
47
+ end
48
+
49
+ private
50
+
51
+ attr_reader :analyzers, :collector, :reporter, :container
52
+
53
+ def process commits
54
+ collector.clear
55
+ commits.map { |commit| analyze commit }
56
+ end
57
+
58
+ def analyze commit
59
+ settings.map { |setting| load_analyzer commit, setting.id }
60
+ .select(&:enabled?)
61
+ .map { |analyzer| collector.add analyzer }
62
+ end
63
+
64
+ def load_analyzer commit, id
65
+ analyzers.find { |analyzer| analyzer.id == id }
66
+ .then do |analyzer|
67
+ fail Errors::Base, "Invalid analyzer detected: #{id}." unless analyzer
68
+
69
+ analyzer.new commit
70
+ end
71
+ end
72
+
73
+ def settings = container[:configuration].analyzers
74
+ end
75
+ end
76
+ end