git-lint 2.3.2 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
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 +208 -223
  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 +3 -2
  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 +3 -3
  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,14 +12,14 @@ 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
 
21
- A command line interface for linting Git commits. Ensures you maintain a clean, easy to read,
22
- debuggable, and maintainable project history.
18
+ Git Lint is a command line interface for linting Git commits by ensuring you maintain a clean, easy
19
+ to read, debuggable, and maintainable project history. Having a consistent commit history leads to
20
+ improved code reviews and is a perfect companion to tools like
21
+ link:https://www.alchemists.io/projects/milestoner[Milestoner] for versioning and producing
22
+ automated release notes of your deploys.
23
23
 
24
24
  toc::[]
25
25
 
@@ -32,11 +32,6 @@ toc::[]
32
32
  * Provides Git Hook support for local use.
33
33
  * Provides Continuous Integration (CI) support.
34
34
 
35
- == Screencasts
36
-
37
- [link=https://www.alchemists.io/screencasts/git_lint]
38
- image::https://www.alchemists.io/images/screencasts/git_lint/cover.svg[Screencast,600,240,role=focal_point]
39
-
40
35
  == Requirements
41
36
 
42
37
  . link:https://www.ruby-lang.org[Ruby]
@@ -50,6 +45,23 @@ To install, run:
50
45
  gem install git-lint
51
46
  ----
52
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
+
53
65
  == Usage
54
66
 
55
67
  === Command Line Interface (CLI)
@@ -57,11 +69,15 @@ gem install git-lint
57
69
  From the command line, type: `git-lint --help`
58
70
 
59
71
  ....
60
- git-lint --hook # Add Git Hook support.
61
- git-lint -a, [--analyze] # Analyze feature branch for issues.
62
- git-lint -c, [--config] # Manage gem configuration.
63
- git-lint -h, [--help=COMMAND] # Show this message or get help for a command.
64
- 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.
65
81
  ....
66
82
 
67
83
  To check if your Git commit history is clean, run: `git-lint --analyze`. It will exit with a failure
@@ -109,7 +125,8 @@ require "git/lint/rake/setup"
109
125
 
110
126
  Now, when running `bundle exec rake -T`, you'll see `git_lint` included in the list.
111
127
 
112
- 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.
113
130
 
114
131
  === Default Branch
115
132
 
@@ -139,124 +156,124 @@ variables. The default configuration is:
139
156
 
140
157
  [source,yaml]
141
158
  ----
142
- :commit_author_capitalization:
143
- :enabled: true
144
- :severity: :error
145
- :commit_author_email:
146
- :enabled: true
147
- :severity: :error
148
- :commit_author_name:
149
- :enabled: true
150
- :severity: :error
151
- :minimum: 2
152
- :commit_body_bullet:
153
- :enabled: true
154
- :severity: :error
155
- :excludes:
156
- - "\\*"
157
- - ""
158
- :commit_body_bullet_capitalization:
159
- :enabled: true
160
- :severity: :error
161
- :includes: "\\-"
162
- :commit_body_bullet_delimiter:
163
- :enabled: true
164
- :severity: :error
165
- :includes: "\\-"
166
- :commit_body_issue_tracker_link:
167
- :enabled: true
168
- :severity: :error
169
- :excludes:
170
- - "(f|F)ix(es|ed)?\\s\\#\\d+"
171
- - "(c|C)lose(s|d)?\\s\\#\\d+"
172
- - "(r|R)esolve(s|d)?\\s\\#\\d+"
173
- - "github\\.com\\/.+\\/issues\\/\\d+"
174
- :commit_body_leading_line:
175
- :enabled: false
176
- :severity: :warn
177
- :commit_body_line_length:
178
- :enabled: true
179
- :severity: :error
180
- :length: 72
181
- :commit_body_paragraph_capitalization:
182
- :enabled: true
183
- :severity: :error
184
- :commit_body_phrase:
185
- :enabled: true
186
- :severity: :error
187
- :excludes:
188
- - "absolutely"
189
- - "actually"
190
- - "all intents and purposes"
191
- - "along the lines"
192
- - "at this moment in time"
193
- - "basically"
194
- - "each and every one"
195
- - "everyone knows"
196
- - "fact of the matter"
197
- - "furthermore"
198
- - "however"
199
- - "in due course"
200
- - "in the end"
201
- - "last but not least"
202
- - "matter of fact"
203
- - "obviously"
204
- - "of course"
205
- - "really"
206
- - "simply"
207
- - "things being equal"
208
- - "would like to"
209
- - "/\\beasy\\b/"
210
- - "/\\bjust\\b/"
211
- - "/\\bquite\\b/"
212
- - "/as\\sfar\\sas\\s.+\\sconcerned/"
213
- - "/of\\sthe\\s(fact|opinion)\\sthat/"
214
- :commit_body_presence:
215
- :enabled: false
216
- :severity: :warn
217
- :minimum: 1
218
- :commit_body_single_bullet:
219
- :enabled: true
220
- :severity: :error
221
- :includes: "\\-"
222
- :commit_subject_length:
223
- :enabled: true
224
- :severity: :error
225
- :length: 72
226
- :commit_subject_prefix:
227
- :enabled: true
228
- :severity: :error
229
- :includes:
230
- - Fixed
231
- - Added
232
- - Updated
233
- - Removed
234
- - Refactored
235
- :commit_subject_suffix:
236
- :enabled: true
237
- :severity: :error
238
- :excludes:
239
- - "\\."
240
- - "\\?"
241
- - "\\!"
242
- :commit_trailer_collaborator_capitalization:
243
- :enabled: true
244
- :severity: :error
245
- :commit_trailer_collaborator_duplication:
246
- :enabled: true
247
- :severity: :error
248
- :commit_trailer_collaborator_email:
249
- :enabled: true
250
- :severity: :error
251
- :commit_trailer_collaborator_key:
252
- :enabled: true
253
- :severity: :error
254
- :includes:
255
- - "Co-Authored-By"
256
- :commit_trailer_collaborator_name:
257
- :enabled: true
258
- :severity: :error
259
- :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
260
277
  ----
261
278
 
262
279
  Feel free to take this default configuration, modify, and save as your own custom
@@ -312,18 +329,15 @@ any of the scripts within the `.git/hooks` directory of the repository.
312
329
 
313
330
  ==== Commit Message
314
331
 
315
- The _commit-msg_ hook, which is the best way to use this gem as a Git Hook, is provided as a
316
- `--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:
317
334
 
318
- Usage:
319
- git-lint --hook
320
-
321
- Options:
322
- [--commit-message=PATH] # Check commit message.
323
-
324
- Add Git Hook support.
335
+ [source,bash]
336
+ ----
337
+ git-lint --hook PATH
338
+ ----
325
339
 
326
- 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
327
341
  is provided to you by Git within the `.git/hooks/commit-msg` script. Here is a working example of
328
342
  what that script might look like:
329
343
 
@@ -341,27 +355,22 @@ if ! command -v git-lint > /dev/null; then
341
355
  exit 1
342
356
  fi
343
357
 
344
- git-lint --hook --commit-message "${BASH_ARGV[0]}"
358
+ git-lint --hook "${BASH_ARGV[0]}"
345
359
  ----
346
360
 
347
361
  Whenever you attempt to add a commit, Git Lint will check your commit for issues prior to saving it.
348
362
 
349
363
  ==== Post Commit
350
364
 
351
- The _post-commit_ hook is possible via the `--analyze --commits` option. Usage:
352
-
353
- ....
354
- Usage:
355
- git-lint -a, [--analyze]
356
-
357
- Options:
358
- -c, [--commits=one two three] # Analyze specific commit SHA(s).
365
+ The _post-commit_ hook is possible via the `--analyze` command. Usage:
359
366
 
360
- Analyze feature branch for issues.
361
- ....
367
+ [source,bash]
368
+ ----
369
+ git-lint --analyze --shas SHA
370
+ ----
362
371
 
363
- The _post-commit_ hook can be used multiple ways but, if you want it to check each commit after it
364
- 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:
365
374
 
366
375
  [source,bash]
367
376
  ----
@@ -377,7 +386,7 @@ if ! command -v git-lint > /dev/null; then
377
386
  exit 1
378
387
  fi
379
388
 
380
- git-lint --analyze --commits $(git log --pretty=format:%H -1)
389
+ git-lint --analyze --shas $(git log --pretty=format:%H -1)
381
390
  ----
382
391
 
383
392
  Whenever a commit has been saved, this script will run Git Lint to check for issues.
@@ -431,11 +440,6 @@ The above will ensure Git Lint runs as an additional check on each Pull Request.
431
440
  Detection and configuration happens automatically by checking the `NETLIFY` environment variable. No
432
441
  additional setup required!
433
442
 
434
- ==== link:https://travis-ci.org[Travis CI]
435
-
436
- Detection and configuration happens automatically by checking the `TRAVIS` environment variable. No
437
- additional setup required!
438
-
439
443
  == Analyzers
440
444
 
441
445
  The following details the various analyzers provided by this gem to ensure a high standard of
@@ -554,38 +558,6 @@ Ensures commit body bullets are delimited by a space. Example:
554
558
  - An example bullet.
555
559
  ....
556
560
 
557
- === Commit Body Issue Tracker Link
558
-
559
- [options="header"]
560
- |===
561
- | Enabled | Severity | Defaults
562
- | true | error | excludes: (see configuration)
563
- |===
564
-
565
- Ensures commit body doesn't contain a link to an issue tracker. The exclude list defaults to GitHub
566
- Issue links but can be customized for any issue tracker.
567
-
568
- There are several reasons for excluding issue tracker links from commit bodies:
569
-
570
- . Not all issue trackers preserve issues (meaning they can be deleted). This makes make reading
571
- historic commits much harder to understand why the change was made when the link no longer works.
572
- . When not connected to the internet or working on a laggy connection, it's hard to understand why
573
- a commit was made when all you have is a link to an issue with no other supporting context.
574
- . During the course of a repository's life, issue trackers can be replaced (rare but it does
575
- happen). If the old issue tracker service is no longer paid for, none of the links within the
576
- commit will be of any relevance.
577
- . An issue might span several commits in order to resolve it. Including a link in each commit is
578
- tedious and can create noise within the issue's history which is distracting.
579
-
580
- Instead of linking to issues, take the time to write a short summary as to _why_ the commit was
581
- made. Doing this will make it easier to understand _why_ the commit was made, keeps the commit self-
582
- contained, and makes learning about/debugging the commit faster.
583
-
584
- Issue tracker links are best used at the code review level due to an issue usually spanning multiple
585
- commits in order to complete the work. When reading a code review, this is a great opportunity to
586
- link to an issue in order to provide a high level overview and reason why the code review was
587
- initiated in the first place.
588
-
589
561
  === Commit Body Leading Line
590
562
 
591
563
  [options="header"]
@@ -622,13 +594,12 @@ ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, orn
622
594
  [options="header"]
623
595
  |===
624
596
  | Enabled | Severity | Defaults
625
- | true | error | length: 72
597
+ | true | error | maximum: 72
626
598
  |===
627
599
 
628
- Ensures each line of the commit body is no longer than 72 characters in length for consistent
629
- readability and word-wrap prevention on smaller screen sizes. For further details, read Tim Pope's
630
- original link:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[article] on the
631
- 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.
632
603
 
633
604
  === Commit Body Paragraph Capitalization
634
605
 
@@ -708,12 +679,37 @@ Pellentque morbi-trist sentus et netus et malesuada fames ac turpis egestas. Ves
708
679
  quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu_libero sit amet quam.
709
680
  ....
710
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
+
711
707
  === Commit Subject Length
712
708
 
713
709
  [options="header"]
714
710
  |===
715
711
  | Enabled | Severity | Defaults
716
- | true | error | length: 72
712
+ | true | error | maximum: 72
717
713
  |===
718
714
 
719
715
  Ensures the commit subject length is no more than 72 characters in length. This default is more
@@ -902,8 +898,9 @@ worth considering:
902
898
  Submodules can accomplish.
903
899
  * Avoid using link:https://git-lfs.github.com[Git LFS] for tracking binary artifacts/resources.
904
900
  These files are not meant for version control and lead to large repositories that are time
905
- consuming to clone/deploy. Use storage managers, like link:https://aws.amazon.com/s3[Amazon S3]
906
- for example, that are better suited for binary assets that don't 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.
907
904
 
908
905
  === Security
909
906
 
@@ -1008,31 +1005,19 @@ To test, run:
1008
1005
  bundle exec rake
1009
1006
  ----
1010
1007
 
1011
- == Versioning
1012
-
1013
- Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
1014
-
1015
- * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
1016
- * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
1017
- * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
1018
-
1019
- == Code of Conduct
1020
-
1021
- Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
1022
- participating in this project you agree to abide by its terms.
1023
-
1024
- == Contributions
1008
+ == link:https://www.alchemists.io/policies/license[License]
1025
1009
 
1026
- Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
1010
+ == link:https://www.alchemists.io/policies/security[Security]
1027
1011
 
1028
- == License
1012
+ == link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
1029
1013
 
1030
- Read link:LICENSE.adoc[LICENSE] for details.
1014
+ == link:https://www.alchemists.io/policies/contributions[Contributions]
1031
1015
 
1032
- == History
1016
+ == link:https://www.alchemists.io/projects/git-lint/versions[Versions]
1033
1017
 
1034
- Read link:CHANGES.adoc[CHANGES] for details.
1018
+ == link:https://www.alchemists.io/community[Community]
1035
1019
 
1036
1020
  == Credits
1037
1021
 
1038
- 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