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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +207 -155
- data/README.adoc +203 -222
- 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 +5 -12
- 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 +55 -29
- 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
|
@@ -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
|
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
|
-
:
|
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
|
-
:commit_body_leading_line:
|
178
|
-
|
179
|
-
|
180
|
-
:commit_body_line_length:
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
:commit_body_paragraph_capitalization:
|
185
|
-
|
186
|
-
|
187
|
-
:commit_body_phrase:
|
188
|
-
|
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
|
-
:commit_body_presence:
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
:commit_body_single_bullet:
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
:commit_subject_length:
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
:commit_subject_prefix:
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
:commit_subject_suffix:
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
:commit_trailer_collaborator_capitalization:
|
246
|
-
|
247
|
-
|
248
|
-
:commit_trailer_collaborator_duplication:
|
249
|
-
|
250
|
-
|
251
|
-
:commit_trailer_collaborator_email:
|
252
|
-
|
253
|
-
|
254
|
-
:commit_trailer_collaborator_key:
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
:commit_trailer_collaborator_name:
|
260
|
-
|
261
|
-
|
262
|
-
|
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
|
319
|
-
`--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:
|
320
334
|
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
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 `--
|
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
|
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
|
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
|
-
|
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,
|
367
|
-
|
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 --
|
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 |
|
597
|
+
| true | error | maximum: 72
|
629
598
|
|===
|
630
599
|
|
631
|
-
Ensures each line of the commit body
|
632
|
-
|
633
|
-
|
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 |
|
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
|
909
|
-
link:https://lakefs.io[LakeFS]
|
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
|
-
==
|
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
|
-
|
1010
|
+
== link:https://www.alchemists.io/policies/security[Security]
|
1031
1011
|
|
1032
|
-
==
|
1012
|
+
== link:https://www.alchemists.io/policies/code_of_conduct[Code of Conduct]
|
1033
1013
|
|
1034
|
-
|
1014
|
+
== link:https://www.alchemists.io/policies/contributions[Contributions]
|
1035
1015
|
|
1036
|
-
==
|
1016
|
+
== link:https://www.alchemists.io/projects/git-lint/versions[Versions]
|
1037
1017
|
|
1038
|
-
|
1018
|
+
== link:https://www.alchemists.io/community[Community]
|
1039
1019
|
|
1040
1020
|
== Credits
|
1041
1021
|
|
1042
|
-
|
1022
|
+
* Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
|
1023
|
+
* 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
|