mirror of
https://github.com/webiny/action-conventional-commits.git
synced 2024-11-23 10:21:51 +01:00
fix: regex
This commit is contained in:
parent
2f1b82c9db
commit
10dafee2e8
3 changed files with 6 additions and 4 deletions
4
dist/main/index.js
vendored
4
dist/main/index.js
vendored
|
@ -453,8 +453,8 @@ const isValidCommitMessage = (message, availableTypes = DEFAULT_COMMIT_TYPES) =>
|
||||||
let [possiblyValidCommitType] = message.split(":");
|
let [possiblyValidCommitType] = message.split(":");
|
||||||
possiblyValidCommitType = possiblyValidCommitType.toLowerCase();
|
possiblyValidCommitType = possiblyValidCommitType.toLowerCase();
|
||||||
// Let's remove scope if present.
|
// Let's remove scope if present.
|
||||||
if (possiblyValidCommitType.match(/\([a-z]*?\)/)) {
|
if (possiblyValidCommitType.match(/\(\S*?\)/)) {
|
||||||
possiblyValidCommitType = possiblyValidCommitType.replace(/\([a-z]*?\)/, "");
|
possiblyValidCommitType = possiblyValidCommitType.replace(/\(\S*?\)/, "");
|
||||||
}
|
}
|
||||||
possiblyValidCommitType = possiblyValidCommitType
|
possiblyValidCommitType = possiblyValidCommitType
|
||||||
.replace(/\s/g, "") // Remove all whitespace
|
.replace(/\s/g, "") // Remove all whitespace
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import isValidCommitMessage from "../isValidCommitMesage";
|
import isValidCommitMessage from "../isValidCommitMesage";
|
||||||
|
|
||||||
test("should be able to correctly validate the commit message", () => {
|
test("should be able to correctly validate the commit message", () => {
|
||||||
|
expect(isValidCommitMessage("chore(nice-one): doing this right")).toBe(true);
|
||||||
expect(isValidCommitMessage("fix: menu must open on shortcut press")).toBe(true);
|
expect(isValidCommitMessage("fix: menu must open on shortcut press")).toBe(true);
|
||||||
expect(isValidCommitMessage("something: should not work")).toBe(false);
|
expect(isValidCommitMessage("something: should not work")).toBe(false);
|
||||||
expect(isValidCommitMessage("fixes something")).toBe(false);
|
expect(isValidCommitMessage("fixes something")).toBe(false);
|
||||||
|
@ -9,4 +10,5 @@ test("should be able to correctly validate the commit message", () => {
|
||||||
expect(isValidCommitMessage("🚧 fix(menus): menu must open on shortcut press")).toBe(true);
|
expect(isValidCommitMessage("🚧 fix(menus): menu must open on shortcut press")).toBe(true);
|
||||||
expect(isValidCommitMessage("🚧 fixing something")).toBe(false);
|
expect(isValidCommitMessage("🚧 fixing something")).toBe(false);
|
||||||
expect(isValidCommitMessage("🚧 something: should not work")).toBe(false);
|
expect(isValidCommitMessage("🚧 something: should not work")).toBe(false);
|
||||||
|
expect(isValidCommitMessage("chorz: 123")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,8 +18,8 @@ const isValidCommitMessage = (message, availableTypes = DEFAULT_COMMIT_TYPES): b
|
||||||
possiblyValidCommitType = possiblyValidCommitType.toLowerCase();
|
possiblyValidCommitType = possiblyValidCommitType.toLowerCase();
|
||||||
|
|
||||||
// Let's remove scope if present.
|
// Let's remove scope if present.
|
||||||
if (possiblyValidCommitType.match(/\([a-z]*?\)/)) {
|
if (possiblyValidCommitType.match(/\(\S*?\)/)) {
|
||||||
possiblyValidCommitType = possiblyValidCommitType.replace(/\([a-z]*?\)/, "");
|
possiblyValidCommitType = possiblyValidCommitType.replace(/\(\S*?\)/, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
possiblyValidCommitType = possiblyValidCommitType
|
possiblyValidCommitType = possiblyValidCommitType
|
||||||
|
|
Loading…
Reference in a new issue