git-lint 2.4.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +207 -155
- data/README.adoc +201 -203
- data/{bin → exe}/git-lint +1 -3
- data/lib/git/lint/analyzer.rb +76 -0
- data/lib/git/lint/analyzers/abstract.rb +8 -18
- data/lib/git/lint/analyzers/commit_author_capitalization.rb +3 -9
- data/lib/git/lint/analyzers/commit_author_email.rb +3 -9
- data/lib/git/lint/analyzers/commit_author_name.rb +5 -14
- data/lib/git/lint/analyzers/commit_body_bullet.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_bullet_capitalization.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_bullet_delimiter.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_leading_line.rb +1 -7
- data/lib/git/lint/analyzers/commit_body_line_length.rb +4 -11
- data/lib/git/lint/analyzers/commit_body_paragraph_capitalization.rb +1 -7
- data/lib/git/lint/analyzers/commit_body_phrase.rb +2 -38
- data/lib/git/lint/analyzers/commit_body_presence.rb +4 -11
- data/lib/git/lint/analyzers/commit_body_single_bullet.rb +2 -9
- data/lib/git/lint/analyzers/commit_body_tracker_shorthand.rb +27 -0
- data/lib/git/lint/analyzers/commit_subject_length.rb +4 -11
- data/lib/git/lint/analyzers/commit_subject_prefix.rb +2 -9
- data/lib/git/lint/analyzers/commit_subject_suffix.rb +2 -13
- data/lib/git/lint/analyzers/commit_trailer_collaborator_capitalization.rb +3 -12
- data/lib/git/lint/analyzers/commit_trailer_collaborator_duplication.rb +3 -11
- data/lib/git/lint/analyzers/commit_trailer_collaborator_email.rb +3 -12
- data/lib/git/lint/analyzers/commit_trailer_collaborator_key.rb +4 -13
- data/lib/git/lint/analyzers/commit_trailer_collaborator_name.rb +5 -15
- data/lib/git/lint/cli/actions/analyze/branch.rb +43 -0
- data/lib/git/lint/cli/actions/analyze/commit.rb +44 -0
- data/lib/git/lint/cli/actions/config.rb +37 -0
- data/lib/git/lint/cli/actions/hook.rb +34 -0
- data/lib/git/lint/cli/parser.rb +33 -0
- data/lib/git/lint/cli/parsers/analyze.rb +40 -0
- data/lib/git/lint/cli/parsers/core.rb +72 -0
- data/lib/git/lint/cli/shell.rb +56 -0
- data/lib/git/lint/collector.rb +3 -4
- data/lib/git/lint/commits/container.rb +19 -0
- data/lib/git/lint/commits/loader.rb +51 -0
- data/lib/git/lint/commits/systems/circle_ci.rb +26 -0
- data/lib/git/lint/{branches/environments → commits/systems}/git_hub_action.rb +10 -8
- data/lib/git/lint/commits/systems/local.rb +26 -0
- data/lib/git/lint/{branches/environments → commits/systems}/netlify_ci.rb +14 -10
- data/lib/git/lint/configuration/content.rb +26 -0
- data/lib/git/lint/configuration/defaults.yml +118 -0
- data/lib/git/lint/configuration/loader.rb +50 -0
- data/lib/git/lint/configuration/setting.rb +24 -0
- data/lib/git/lint/container.rb +41 -0
- data/lib/git/lint/errors/severity.rb +1 -0
- data/lib/git/lint/errors/sha.rb +1 -0
- data/lib/git/lint/identity.rb +2 -1
- data/lib/git/lint/kit/filter_list.rb +1 -1
- data/lib/git/lint/parsers/trailers/collaborator.rb +1 -0
- data/lib/git/lint/rake/tasks.rb +5 -4
- data/lib/git/lint/reporters/branch.rb +12 -6
- data/lib/git/lint/reporters/commit.rb +3 -1
- data/lib/git/lint/reporters/line.rb +3 -5
- data/lib/git/lint/reporters/lines/paragraph.rb +3 -0
- data/lib/git/lint/reporters/lines/sentence.rb +3 -0
- data/lib/git/lint/reporters/style.rb +3 -1
- data/lib/git/lint/validators/capitalization.rb +1 -0
- data/lib/git/lint/validators/email.rb +1 -0
- data/lib/git/lint/validators/name.rb +1 -0
- data/lib/git/lint.rb +18 -47
- data.tar.gz.sig +0 -0
- metadata +54 -28
- metadata.gz.sig +0 -0
- data/lib/git/lint/analyzers/commit_body_issue_tracker_link.rb +0 -39
- data/lib/git/lint/branches/environments/circle_ci.rb +0 -24
- data/lib/git/lint/branches/environments/local.rb +0 -24
- data/lib/git/lint/branches/environments/travis_ci.rb +0 -49
- data/lib/git/lint/branches/feature.rb +0 -42
- data/lib/git/lint/cli.rb +0 -117
- data/lib/git/lint/refinements/strings.rb +0 -21
- 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
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
@@ -143,124 +156,124 @@ variables. The default configuration is:
|
|
143
156
|
|
144
157
|
[source,yaml]
|
145
158
|
----
|
146
|
-
:
|
147
|
-
:
|
148
|
-
|
149
|
-
:
|
150
|
-
:
|
151
|
-
|
152
|
-
:
|
153
|
-
:
|
154
|
-
|
155
|
-
|
156
|
-
:
|
157
|
-
:
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
:
|
164
|
-
|
165
|
-
|
166
|
-
:
|
167
|
-
:
|
168
|
-
|
169
|
-
|
170
|
-
:
|
171
|
-
:
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
:commit_body_leading_line:
|
179
|
-
|
180
|
-
|
181
|
-
:commit_body_line_length:
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
:commit_body_paragraph_capitalization:
|
186
|
-
|
187
|
-
|
188
|
-
:commit_body_phrase:
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
:commit_body_presence:
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
:commit_body_single_bullet:
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
:commit_subject_length:
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
:commit_subject_prefix:
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
:commit_subject_suffix:
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
:commit_trailer_collaborator_capitalization:
|
247
|
-
|
248
|
-
|
249
|
-
:commit_trailer_collaborator_duplication:
|
250
|
-
|
251
|
-
|
252
|
-
:commit_trailer_collaborator_email:
|
253
|
-
|
254
|
-
|
255
|
-
:commit_trailer_collaborator_key:
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
:commit_trailer_collaborator_name:
|
261
|
-
|
262
|
-
|
263
|
-
|
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
|
264
277
|
----
|
265
278
|
|
266
279
|
Feel free to take this default configuration, modify, and save as your own custom
|
@@ -316,18 +329,15 @@ any of the scripts within the `.git/hooks` directory of the repository.
|
|
316
329
|
|
317
330
|
==== Commit Message
|
318
331
|
|
319
|
-
The _commit-msg_ hook
|
320
|
-
`--hook` option.
|
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:
|
321
334
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
[--commit-message=PATH] # Check commit message.
|
327
|
-
|
328
|
-
Add Git Hook support.
|
335
|
+
[source,bash]
|
336
|
+
----
|
337
|
+
git-lint --hook PATH
|
338
|
+
----
|
329
339
|
|
330
|
-
As shown above, the `--
|
340
|
+
As shown above, the `--hook` command accepts a file path (i.e. `.git/COMMIT_EDITMSG`) which
|
331
341
|
is provided to you by Git within the `.git/hooks/commit-msg` script. Here is a working example of
|
332
342
|
what that script might look like:
|
333
343
|
|
@@ -345,27 +355,22 @@ if ! command -v git-lint > /dev/null; then
|
|
345
355
|
exit 1
|
346
356
|
fi
|
347
357
|
|
348
|
-
git-lint --hook
|
358
|
+
git-lint --hook "${BASH_ARGV[0]}"
|
349
359
|
----
|
350
360
|
|
351
361
|
Whenever you attempt to add a commit, Git Lint will check your commit for issues prior to saving it.
|
352
362
|
|
353
363
|
==== Post Commit
|
354
364
|
|
355
|
-
The _post-commit_ hook is possible via the `--analyze
|
356
|
-
|
357
|
-
....
|
358
|
-
Usage:
|
359
|
-
git-lint -a, [--analyze]
|
360
|
-
|
361
|
-
Options:
|
362
|
-
-c, [--commits=one two three] # Analyze specific commit SHA(s).
|
365
|
+
The _post-commit_ hook is possible via the `--analyze` command. Usage:
|
363
366
|
|
364
|
-
|
365
|
-
|
367
|
+
[source,bash]
|
368
|
+
----
|
369
|
+
git-lint --analyze --shas SHA
|
370
|
+
----
|
366
371
|
|
367
|
-
The _post-commit_ hook can be used multiple ways but,
|
368
|
-
|
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:
|
369
374
|
|
370
375
|
[source,bash]
|
371
376
|
----
|
@@ -381,7 +386,7 @@ if ! command -v git-lint > /dev/null; then
|
|
381
386
|
exit 1
|
382
387
|
fi
|
383
388
|
|
384
|
-
git-lint --analyze --
|
389
|
+
git-lint --analyze --shas $(git log --pretty=format:%H -1)
|
385
390
|
----
|
386
391
|
|
387
392
|
Whenever a commit has been saved, this script will run Git Lint to check for issues.
|
@@ -435,11 +440,6 @@ The above will ensure Git Lint runs as an additional check on each Pull Request.
|
|
435
440
|
Detection and configuration happens automatically by checking the `NETLIFY` environment variable. No
|
436
441
|
additional setup required!
|
437
442
|
|
438
|
-
==== link:https://travis-ci.org[Travis CI]
|
439
|
-
|
440
|
-
Detection and configuration happens automatically by checking the `TRAVIS` environment variable. No
|
441
|
-
additional setup required!
|
442
|
-
|
443
443
|
== Analyzers
|
444
444
|
|
445
445
|
The following details the various analyzers provided by this gem to ensure a high standard of
|
@@ -558,38 +558,6 @@ Ensures commit body bullets are delimited by a space. Example:
|
|
558
558
|
- An example bullet.
|
559
559
|
....
|
560
560
|
|
561
|
-
=== Commit Body Issue Tracker Link
|
562
|
-
|
563
|
-
[options="header"]
|
564
|
-
|===
|
565
|
-
| Enabled | Severity | Defaults
|
566
|
-
| true | error | excludes: (see configuration)
|
567
|
-
|===
|
568
|
-
|
569
|
-
Ensures commit body doesn't contain a link to an issue tracker. The exclude list defaults to GitHub
|
570
|
-
Issue links but can be customized for any issue tracker.
|
571
|
-
|
572
|
-
There are several reasons for excluding issue tracker links from commit bodies:
|
573
|
-
|
574
|
-
. Not all issue trackers preserve issues (meaning they can be deleted). This makes make reading
|
575
|
-
historic commits much harder to understand why the change was made when the link no longer works.
|
576
|
-
. When not connected to the internet or working on a laggy connection, it's hard to understand why
|
577
|
-
a commit was made when all you have is a link to an issue with no other supporting context.
|
578
|
-
. During the course of a repository's life, issue trackers can be replaced (rare but it does
|
579
|
-
happen). If the old issue tracker service is no longer paid for, none of the links within the
|
580
|
-
commit will be of any relevance.
|
581
|
-
. An issue might span several commits in order to resolve it. Including a link in each commit is
|
582
|
-
tedious and can create noise within the issue's history which is distracting.
|
583
|
-
|
584
|
-
Instead of linking to issues, take the time to write a short summary as to _why_ the commit was
|
585
|
-
made. Doing this will make it easier to understand _why_ the commit was made, keeps the commit self-
|
586
|
-
contained, and makes learning about/debugging the commit faster.
|
587
|
-
|
588
|
-
Issue tracker links are best used at the code review level due to an issue usually spanning multiple
|
589
|
-
commits in order to complete the work. When reading a code review, this is a great opportunity to
|
590
|
-
link to an issue in order to provide a high level overview and reason why the code review was
|
591
|
-
initiated in the first place.
|
592
|
-
|
593
561
|
=== Commit Body Leading Line
|
594
562
|
|
595
563
|
[options="header"]
|
@@ -626,13 +594,12 @@ ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, orn
|
|
626
594
|
[options="header"]
|
627
595
|
|===
|
628
596
|
| Enabled | Severity | Defaults
|
629
|
-
| true | error |
|
597
|
+
| true | error | maximum: 72
|
630
598
|
|===
|
631
599
|
|
632
|
-
Ensures each line of the commit body
|
633
|
-
|
634
|
-
|
635
|
-
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.
|
636
603
|
|
637
604
|
=== Commit Body Paragraph Capitalization
|
638
605
|
|
@@ -712,12 +679,37 @@ Pellentque morbi-trist sentus et netus et malesuada fames ac turpis egestas. Ves
|
|
712
679
|
quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu_libero sit amet quam.
|
713
680
|
....
|
714
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
|
+
|
715
707
|
=== Commit Subject Length
|
716
708
|
|
717
709
|
[options="header"]
|
718
710
|
|===
|
719
711
|
| Enabled | Severity | Defaults
|
720
|
-
| true | error |
|
712
|
+
| true | error | maximum: 72
|
721
713
|
|===
|
722
714
|
|
723
715
|
Ensures the commit subject length is no more than 72 characters in length. This default is more
|
@@ -906,9 +898,9 @@ worth considering:
|
|
906
898
|
Submodules can accomplish.
|
907
899
|
* Avoid using link:https://git-lfs.github.com[Git LFS] for tracking binary artifacts/resources.
|
908
900
|
These files are not meant for version control and lead to large repositories that are time
|
909
|
-
consuming to clone/deploy. Use storage managers
|
910
|
-
link:https://lakefs.io[LakeFS]
|
911
|
-
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.
|
912
904
|
|
913
905
|
=== Security
|
914
906
|
|
@@ -1030,14 +1022,20 @@ participating in this project you agree to abide by its terms.
|
|
1030
1022
|
|
1031
1023
|
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
1032
1024
|
|
1025
|
+
== Community
|
1026
|
+
|
1027
|
+
Feel free to link:https://www.alchemists.io/community[join the commmunity] for discussions related
|
1028
|
+
to this project and much more.
|
1029
|
+
|
1033
1030
|
== License
|
1034
1031
|
|
1035
1032
|
Read link:LICENSE.adoc[LICENSE] for details.
|
1036
1033
|
|
1037
|
-
==
|
1034
|
+
== Changes
|
1038
1035
|
|
1039
1036
|
Read link:CHANGES.adoc[CHANGES] for details.
|
1040
1037
|
|
1041
1038
|
== Credits
|
1042
1039
|
|
1043
|
-
|
1040
|
+
* Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
|
1041
|
+
* Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
|
data/{bin → exe}/git-lint
RENAMED
@@ -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
|
@@ -12,36 +12,24 @@ module Git
|
|
12
12
|
LEVELS = %i[warn error].freeze
|
13
13
|
ISSUE_LINE_OFFSET = 2
|
14
14
|
|
15
|
-
def self.inherited klass
|
16
|
-
super
|
17
|
-
@descendants ||= []
|
18
|
-
@descendants << klass unless klass.to_s.start_with? "#<Class" # Ignore anonymous classes.
|
19
|
-
end
|
20
|
-
|
21
15
|
def self.id = to_s.delete_prefix("Git::Lint::Analyzers").snakecase.to_sym
|
22
16
|
|
23
17
|
def self.label = to_s.delete_prefix("Git::Lint::Analyzers").titleize
|
24
18
|
|
25
|
-
def self.defaults
|
26
|
-
fail NotImplementedError, "The `.#{__method__}` method must be implemented."
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.descendants = @descendants || []
|
30
|
-
|
31
19
|
def self.build_issue_line(index, line) = {number: index + ISSUE_LINE_OFFSET, content: line}
|
32
20
|
|
33
21
|
attr_reader :commit
|
34
22
|
|
35
|
-
def initialize commit
|
23
|
+
def initialize commit, container: Container
|
36
24
|
@commit = commit
|
37
|
-
@
|
25
|
+
@container = container
|
38
26
|
@filter_list = load_filter_list
|
39
27
|
end
|
40
28
|
|
41
|
-
def enabled? = settings.
|
29
|
+
def enabled? = settings.enabled
|
42
30
|
|
43
31
|
def severity
|
44
|
-
settings.
|
32
|
+
settings.severity.tap do |level|
|
45
33
|
fail Errors::Severity, level unless LEVELS.include? level
|
46
34
|
end
|
47
35
|
end
|
@@ -62,9 +50,9 @@ module Git
|
|
62
50
|
|
63
51
|
protected
|
64
52
|
|
65
|
-
attr_reader :
|
53
|
+
attr_reader :container, :filter_list
|
66
54
|
|
67
|
-
def load_filter_list =
|
55
|
+
def load_filter_list = []
|
68
56
|
|
69
57
|
def affected_commit_body_lines
|
70
58
|
commit.body_lines.each.with_object([]).with_index do |(line, lines), index|
|
@@ -85,6 +73,8 @@ module Git
|
|
85
73
|
def invalid_line? _line
|
86
74
|
fail NotImplementedError, "The `.#{__method__}` method must be implemented."
|
87
75
|
end
|
76
|
+
|
77
|
+
def settings = container[:configuration].find_setting(self.class.id)
|
88
78
|
end
|
89
79
|
end
|
90
80
|
end
|