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

Merge commit message wrong validated #1887

Closed
1 of 4 tasks
sevakraynov opened this issue Jun 9, 2020 · 5 comments
Closed
1 of 4 tasks

Merge commit message wrong validated #1887

sevakraynov opened this issue Jun 9, 2020 · 5 comments

Comments

@sevakraynov
Copy link

sevakraynov commented Jun 9, 2020

I having issues with validate merge commit message.

Expected Behavior

Commitlint check merge commit message.

Current Behavior

Merge commit message wrong validated.

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Steps to Reproduce (for bugs)

I run this script

 echo "Merge branch 'features/3143' of https://foo.host.com/FooTeam/FooProject/_git/FooProject into features/3143" | npx commitlint --config ./.vsts/config/commitlint.js --verbose

And this message is valid.
image

commitlint.config.js

module.exports = {
	rules: {
		// Тело коммита должно начинаться с пустой строки
		"body-leading-blank": [2, "always"],

		// Максимальная длина строки в теле коммита
		"body-max-line-length": [2, "always", 72],

		// Нижний колонтитул коммита должен начинаться с пустой строки
		"footer-leading-blank": [2, "always"],

		// Максимальная длина строки в нижнем колонтитуле коммита
		"footer-max-line-length": [2, "always", 72],

		// Максимальная длина заголовка 72 символа
		"header-max-length": [2, "always", 72],

		// Область всегда только в нижнем регистре
		"scope-case": [2, "always", "lower-case"],

		// Описание не может быть пустым
		"subject-empty": [2, "never"],

		// Описание не должно заканчиваться '.'
		"subject-full-stop": [2, "never", "."],

		// Тип всегда только в нижнем регистре
		"type-case": [2, "always", "lower-case"],

		// Тип не может быть пустым
		"type-empty": [2, "never"],

		// Перечислим все возможные варианты коммитов
		"type-enum": [
			2,
			"always",
			[
				"build",
				"ci",
				"docs",
				"feat",
				"fix",
				"perf",
				"refactor",
				"revert",
				"style",
				"test",
				"chore",
				"dev"
			]
		]
	}
};

Your Environment

Executable Version
commitlint --version 8.3.5
git --version git version 2.26.2.windows.1
node --version v14.3.0
@Billy-
Copy link

Billy- commented Mar 15, 2021

I have noticed the same issue. I'm sure I used to get errors on merge commits..

@escapedcat
Copy link
Member

By now this is wanted behaviour I believe. Introduced with #2920
See: https://github.com/conventional-changelog/commitlint/releases/tag/v16.0.0
Please reopen if you have questions.

@tony-engineering
Copy link

Hello, I was also surprised to see that this worked:

npx commitlint << EOF
Merge branch 'fix-merge-conflicts' into 'master'
   
Fix merge conflicts in manifests
   
See merge request annea.ai/data!93
EOF

in our case we do not lint every commit, but only the merge commit. I want that if a developer leaves the default message, then the linting fails. We are using Gitlab, it looks like this:
image

Any clue how to achieve this with commitlint ?

@escapedcat
Copy link
Member

@tony-engineering not sure but maybe you can adjust the ignores config:
https://commitlint.js.org/#/reference-configuration?id=configuration-object-example

  /*
   * Functions that return true if commitlint should ignore the given message.
   */
  ignores: [(commit) => commit === ''],
  /*
   * Whether commitlint uses the default ignore rules.
   */

@tony-engineering
Copy link

didn't know about this feature, it worked 🙌
Added this to commitlint.config.js:

    /*
    * Functions that return true if commitlint should ignore the given message.
    */
    ignores: [(commit) => commit === ''],
    /*
    * Whether commitlint uses the default ignore rules.
    */
    defaultIgnores: false,

thank you @escapedcat !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants