pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/gitgitgadget/gitgitgadget/commit/a79b159ab20ce31afac1c678ca031de9097d2da3

anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/global-9c8f61f9f58ad7b2.css" /> Relax lowerCaseAfterPrefix to permit ALLCAPS after prefix · gitgitgadget/gitgitgadget@a79b159 · GitHub
Skip to content

Commit a79b159

Browse files
committed
Relax lowerCaseAfterPrefix to permit ALLCAPS after prefix
We do want to block things like: init: A bad example init: Another bad example However this should be acceptable: init: UNLEAK foo Therefore we tweak the regex to permit ALLCAPS after the prefix. Signed-off-by: Andrzej Hunt <ajrhunt@google.com>
1 parent 3046dff commit a79b159

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

lib/commit-lint.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ export class LintCommit {
8787
}
8888

8989
// Verify if the first line starts with a prefix (e.g. tests:), it continues
90-
// in lower-case
90+
// in lower-case (except for ALLCAPS as that is likely to be a code
91+
// identifier)
9192

9293
private lowerCaseAfterPrefix(): void {
93-
const match = this.lines[0].match(/^\S+?:\s*?([A-Z])/);
94+
const match = this.lines[0].match(/^\S+?:\s*?([A-Z][a-z ])/);
9495

9596
if (match) {
9697
this.block(`Prefixed commit message must be in lower case: ${

tests/commit-lint.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,40 @@ test("basic lint tests", () => {
7676
}
7777
}
7878

79+
commit.message = `tests: A title that should also be lower case\n
80+
Signed-off-by: x`;
81+
{
82+
const linter = new LintCommit(commit);
83+
const lintError = linter.lint();
84+
expect(lintError).not.toBeUndefined();
85+
if (lintError) {
86+
expect(lintError.checkFailed).toBe(true);
87+
expect(lintError.message).toMatch(/lower/);
88+
}
89+
}
90+
91+
commit.message = "tests: THIS can be allcaps\n\nSigned-off-by: x";
92+
{
93+
const linter = new LintCommit(commit);
94+
const lintError = linter.lint();
95+
expect(lintError).toBeUndefined();
96+
}
97+
7998
commit.message = "doc: success as Lower Case\n\nSigned-off-by: x";
8099
{
81100
const linter = new LintCommit(commit);
82101
const lintError = linter.lint();
83102
expect(lintError).toBeUndefined();
84103
}
85104

105+
commit.message = `doc: a single-letter Lower Case message also succeeds\n
106+
Signed-off-by: x`;
107+
{
108+
const linter = new LintCommit(commit);
109+
const lintError = linter.lint();
110+
expect(lintError).toBeUndefined();
111+
}
112+
86113
commit.message = "Fail not signed off\n\nNotSigned-off-by: x";
87114
{
88115
const linter = new LintCommit(commit);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy