git-lint 2.3.1 → 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 +220 -214
- 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 +3 -2
- 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,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
|
-
|
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
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
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
|
-
:
|
143
|
-
:
|
144
|
-
|
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
|
-
:commit_body_leading_line:
|
175
|
-
|
176
|
-
|
177
|
-
:commit_body_line_length:
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
:commit_body_paragraph_capitalization:
|
182
|
-
|
183
|
-
|
184
|
-
:commit_body_phrase:
|
185
|
-
|
186
|
-
|
187
|
-
|
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
|
-
:commit_body_presence:
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
:commit_body_single_bullet:
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
:commit_subject_length:
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
:commit_subject_prefix:
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
:commit_subject_suffix:
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
:commit_trailer_collaborator_capitalization:
|
243
|
-
|
244
|
-
|
245
|
-
:commit_trailer_collaborator_duplication:
|
246
|
-
|
247
|
-
|
248
|
-
:commit_trailer_collaborator_email:
|
249
|
-
|
250
|
-
|
251
|
-
:commit_trailer_collaborator_key:
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
:commit_trailer_collaborator_name:
|
257
|
-
|
258
|
-
|
259
|
-
|
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
|
316
|
-
`--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:
|
317
334
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
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 `--
|
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
|
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
|
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
|
-
|
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,
|
364
|
-
|
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 --
|
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 |
|
597
|
+
| true | error | maximum: 72
|
626
598
|
|===
|
627
599
|
|
628
|
-
Ensures each line of the commit body
|
629
|
-
|
630
|
-
|
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 |
|
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
|
@@ -731,12 +727,12 @@ Automatically ignores _fixup!_ or _squash!_ commit prefixes when calculating sub
|
|
731
727
|
| true | error | includes: (see below)
|
732
728
|
|===
|
733
729
|
|
734
|
-
Ensures
|
730
|
+
Ensures each commit subject uses consistent prefixes that explain _what_ is being committed. The
|
735
731
|
`includes` are _case sensitive_ and default to the following prefixes:
|
736
732
|
|
737
733
|
* *Fixed* - Identifies what was fixed. The commit should be as small as possible and consist of
|
738
|
-
changes to implementation and spec only. In some cases this might be a single line
|
739
|
-
|
734
|
+
changes to implementation and spec only. In some cases this might be a single line change. The
|
735
|
+
important point is the change is applied to existing code which corrects behavior that wasn't
|
740
736
|
properly implemented earlier.
|
741
737
|
* *Removed* - Identifies what was removed. The commit should be as small as possible and consist
|
742
738
|
only of removed lines/files from the existing implementation. This might also mean breaking
|
@@ -754,14 +750,17 @@ Ensures the commit subject uses consistent prefixes that explain _what_ is being
|
|
754
750
|
implementation behavior or corresponding specs because, if that happens, then one of the other
|
755
751
|
four prefixes is what you want to use instead.
|
756
752
|
|
757
|
-
In practice,
|
758
|
-
|
753
|
+
In practice, it is quite rare to need a prefix other than what has been detailed above to explain
|
754
|
+
_what_ is being committed. These prefixes are not only short and easy to remember but also have the
|
759
755
|
added benefit of categorizing the commits for building release notes, change logs, etc. This becomes
|
760
|
-
handy when coupled with another tool,
|
761
|
-
for producing consistent project
|
756
|
+
handy when coupled with another tool,
|
757
|
+
link:https://www.alchemists.io/projects/milestoner[Milestoner], for producing consistent project
|
758
|
+
milestones and Git tag histories. For a deeper dive on subject prefixes and good commit messages in
|
759
|
+
general, please read about link:https://www.alchemists.io/articles/git_commit_anatomy[commit anatomy
|
760
|
+
] to learn more. 🎉
|
762
761
|
|
763
|
-
💡
|
764
|
-
order to not disturb interactive rebase workflows.
|
762
|
+
💡 This analyzer automatically ignores _amend!_, _fixup!_, or _squash!_ commit prefixes when used as
|
763
|
+
a Git Hook in order to not disturb interactive rebase workflows.
|
765
764
|
|
766
765
|
=== Commit Subject Suffix
|
767
766
|
|
@@ -899,8 +898,9 @@ worth considering:
|
|
899
898
|
Submodules can accomplish.
|
900
899
|
* Avoid using link:https://git-lfs.github.com[Git LFS] for tracking binary artifacts/resources.
|
901
900
|
These files are not meant for version control and lead to large repositories that are time
|
902
|
-
consuming to clone/deploy. Use storage managers
|
903
|
-
|
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.
|
904
904
|
|
905
905
|
=== Security
|
906
906
|
|
@@ -1022,14 +1022,20 @@ participating in this project you agree to abide by its terms.
|
|
1022
1022
|
|
1023
1023
|
Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
|
1024
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
|
+
|
1025
1030
|
== License
|
1026
1031
|
|
1027
1032
|
Read link:LICENSE.adoc[LICENSE] for details.
|
1028
1033
|
|
1029
|
-
==
|
1034
|
+
== Changes
|
1030
1035
|
|
1031
1036
|
Read link:CHANGES.adoc[CHANGES] for details.
|
1032
1037
|
|
1033
1038
|
== Credits
|
1034
1039
|
|
1035
|
-
|
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
|