Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(is-ignored): ignore merge tag commit messages #2920

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions @commitlint/is-ignored/src/defaults.ts
Expand Up @@ -18,6 +18,7 @@ export const wildcards: Matcher[] = [
test(
/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m
),
test(/^(Merge tag (.*?))(?:\r?\n)*$/m),
test(/^(R|r)evert (.*)/),
test(/^(fixup|squash)!/),
isSemver,
Expand Down
24 changes: 24 additions & 0 deletions @commitlint/is-ignored/src/is-ignored.test.ts
Expand Up @@ -70,6 +70,26 @@ test('should return true for branch merges with newline characters and more char
);
});

test('should return true for tag merges', () => {
expect(isIgnored("Merge tag '1.1.1'")).toBe(true);
expect(isIgnored("Merge tag 'a tag'")).toBe(true);
});

test('should return true for tag merges with newline characters', () => {
expect(isIgnored("Merge tag '1.1.1'\n")).toBe(true);
expect(isIgnored("Merge tag '1.1.1'\r\n")).toBe(true);
});

test('should return true for tag merges with multiple newline characters', () => {
expect(isIgnored("Merge tag '1.1.1'\n\n\n")).toBe(true);
expect(isIgnored("Merge tag '1.1.1'\r\n\r\n\r\n")).toBe(true);
});

test('should return true for tag merges with newline characters and more characters after it', () => {
expect(isIgnored("Merge tag '1.1.1'\n ")).toBe(true);
expect(isIgnored("Merge tag '1.1.1'\r\n # some comment")).toBe(true);
});

test('should return true for revert commits', () => {
expect(
isIgnored(
Expand Down Expand Up @@ -133,6 +153,10 @@ test('should return false for commits containing, but not starting, with merge b
expect(isIgnored('foo bar Merge branch xxx')).toBe(false);
});

test('should return false for commits containing, but not starting, with merge tag', () => {
expect(isIgnored("foo bar Merge tag '1.1.1'")).toBe(false);
});

test('should return false for ignored message if defaults is false', () => {
expect(
isIgnored('Auto-merged develop into master', {
Expand Down