Skip to content

Commit 1448070

Browse files
committed
Improve regexes in docs
Remove unneeded capturing group parenthesis as there's no significance to the groups, misc strictness fixes, make do the right thing with both match and search style regex matching.
1 parent 4d91197 commit 1448070

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

docs/configuration/gitlint_file.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ regex=My-Commit-Tag: foo$ # (10)
8383

8484
[author-valid-email]
8585
# E.g.: Only allow email addresses from foo.com
86-
regex=[^@][email protected] # (11)
86+
regex=[^@]+@foo\.com$ # (11)
8787

8888

8989
### NAMED RULES ### (20)
@@ -104,20 +104,20 @@ max-line-count = 5
104104
### IGNORE RULES CONFIGURATION ### (13)
105105
[ignore-by-title]
106106
# Ignore rules for commits of which the title matches a regex
107-
regex=^Release(.*) # (14)
107+
regex=^Release.* # (14)
108108
ignore=T1,body-min-length # (15)
109109

110110
[ignore-by-body]
111111
# Ignore rules for commits of which the body has a line that matches a regex
112-
regex=(.*)release(.*) # (16)
112+
regex=.*release.* # (16)
113113
ignore=T1,body-min-length
114114

115115
[ignore-body-lines]
116116
# Ignore all lines that start with 'Co-Authored-By'
117-
regex=^Co-Authored-By # (17)
117+
regex=^Co-Authored-By.* # (17)
118118

119119
[ignore-by-author-name]
120-
regex=(.*)dependabot(.*) # (18)
120+
regex=.*dependabot.* # (18)
121121
ignore=T1,body-min-length
122122
```
123123

@@ -168,7 +168,7 @@ ignore=T1,body-min-length
168168
for commits made by `dependabot`. You can also ignore the the commit all-together by setting `ignore=all`:
169169
```ini
170170
[ignore-by-author-name]
171-
regex=(.*)dependabot(.*) # (18)
171+
regex=.*dependabot.* # (18)
172172
ignore=all
173173
```
174174

docs/ignoring_commits.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Here's a few examples:
1313
```ini
1414
[ignore-by-title]
1515
# Match commit titles starting with "Release"
16-
regex=^Release(.*)
16+
regex=^Release.*
1717
ignore=title-max-length,body-min-length # (1)
1818

1919
[ignore-by-body]
2020
# Match commits message bodies that have a line that contains 'release'
21-
regex=(.*)release(.*)
21+
regex=.*release.*
2222
ignore=all
2323

2424
[ignore-by-author-name]
@@ -30,7 +30,7 @@ Here's a few examples:
3030
1. Ignore all rules by setting `ignore` to 'all'.
3131
```ini
3232
[ignore-by-title]
33-
regex=^Release(.*)
33+
regex=^Release.*
3434
ignore=all
3535
```
3636

@@ -43,7 +43,7 @@ ones, you can do that using the
4343
```ini
4444
# Ignore all lines that start with 'Co-Authored-By'
4545
[ignore-body-lines]
46-
regex=^Co-Authored-By
46+
regex=^Co-Authored-By.*
4747
```
4848

4949
!!! warning

docs/rules/builtin_rules.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ Body must match a given regex.
223223
```ini
224224
# Ensure the body ends with Reviewed-By: <some value>
225225
[body-match-regex]
226-
regex=Reviewed-By:(.*)$
226+
regex=Reviewed-By: .+
227227

228228
# Ensure body contains the word "Foo" somewhere
229229
[body-match-regex]
230-
regex=(*.)Foo(.*)
230+
regex=.*\bFoo\b.*
231231
```
232232

233233
## M1: author-valid-email
@@ -252,7 +252,7 @@ Author email address must be a valid email address.
252252
```ini
253253
# Only allow email addresses from a foo.com domain
254254
[author-valid-email]
255-
255+
regex=[^@]+@foo\.com$
256256
```
257257

258258
## I1: ignore-by-title
@@ -273,12 +273,12 @@ Ignore a commit based on matching its title.
273273
# Match commit titles starting with Release
274274
# For those commits, ignore title-max-length and body-min-length rules
275275
[ignore-by-title]
276-
regex=^Release(.*)
276+
regex=^Release.*
277277
ignore=title-max-length,body-min-length,B6 # (1)
278278

279279
# Ignore all rules by setting ignore to 'all'
280280
[ignore-by-title]
281-
regex=^Release(.*)
281+
regex=^Release.*
282282
ignore=all
283283
```
284284

@@ -303,12 +303,12 @@ Ignore a commit based on matching its body.
303303
# Ignore all commits with a commit message body with a line that contains 'release'
304304
# For matching commits, only ignore rules T1, body-min-length, B6.
305305
[ignore-by-body]
306-
regex=(.*)release(.*)
306+
regex=.*release.*
307307
ignore=T1,body-min-length,B6 # (1)
308308

309309
# Ignore all rules by setting ignore to 'all'
310310
[ignore-by-body]
311-
regex=(.*)release(.*)
311+
regex=.*release.*
312312
ignore=all
313313
```
314314

@@ -331,15 +331,15 @@ Ignore certain lines in a commit body that match a regex.
331331
```ini
332332
# Ignore all lines that start with 'Co-Authored-By'
333333
[ignore-body-lines]
334-
regex=^Co-Authored-By
334+
regex=^Co-Authored-By.*
335335

336336
# Ignore lines that start with 'Co-Authored-By' or with 'Signed-off-by'
337337
[ignore-body-lines]
338-
regex=(^Co-Authored-By)|(^Signed-off-by)
338+
regex=^(Co-Authored-By|Signed-off-by).*
339339

340340
# Ignore lines that contain 'foobar'
341341
[ignore-body-lines]
342-
regex=(.*)foobar(.*)
342+
regex=.*foobar.*
343343
```
344344

345345
## I4: ignore-by-author-name
@@ -365,7 +365,7 @@ Ignore a commit based on matching its author name.
365365

366366
# For commits made by authors with "[bot]" in their name, ignore specific rules
367367
[ignore-by-author-name]
368-
regex=(.*)\[bot\](.*)
368+
regex=.*\[bot\].*
369369
ignore=T1,body-min-length,B6 # (1)
370370
```
371371

gitlint-core/gitlint/files/gitlint

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@
9999
# [author-valid-email]
100100
# python-style regex that the commit author email address must match.
101101
# For example, use the following regex if you only want to allow email addresses from foo.com
102-
# regex=[^@][email protected]
102+
# regex=[^@]+@foo\.com$
103103

104104
# [ignore-by-title]
105105
# Ignore certain rules for commits of which the title matches a regex
106106
# E.g. Match commit titles that start with "Release"
107-
# regex=^Release(.*)
107+
# regex=^Release.*
108108

109109
# Ignore certain rules, you can reference them by their id or by their full name
110110
# Use 'all' to ignore all rules
@@ -113,7 +113,7 @@
113113
# [ignore-by-body]
114114
# Ignore certain rules for commits of which the body has a line that matches a regex
115115
# E.g. Match bodies that have a line that that contain "release"
116-
# regex=(.*)release(.*)
116+
# regex=.*release.*
117117
#
118118
# Ignore certain rules, you can reference them by their id or by their full name
119119
# Use 'all' to ignore all rules
@@ -122,12 +122,12 @@
122122
# [ignore-body-lines]
123123
# Ignore certain lines in a commit body that match a regex.
124124
# E.g. Ignore all lines that start with 'Co-Authored-By'
125-
# regex=^Co-Authored-By
125+
# regex=^Co-Authored-By.*
126126

127127
# [ignore-by-author-name]
128128
# Ignore certain rules for commits of which the author name matches a regex
129129
# E.g. Match commits made by dependabot
130-
# regex=(.*)dependabot(.*)
130+
# regex=.*dependabot.*
131131
#
132132
# Ignore certain rules, you can reference them by their id or by their full name
133133
# Use 'all' to ignore all rules
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[ignore-by-title]
2-
regex=^Release(.*)
2+
regex=^Release.*
33
ignore=T5,T3
44

55
[ignore-by-body]
6-
regex=(.*)relëase(.*)
6+
regex=.*release.*
77
ignore=T3,B3

0 commit comments

Comments
 (0)