conventional-changelog/commitlint

"ignores" commit is not trimmed

開放

#3,162 建立於 2022年5月3日

 (4 則留言) (0 個反應) (0 位負責人)TypeScript (896 個分叉)batch import
bughelp wanted

倉庫指標

星標
 (15,497 顆星)
PR 合併指標
 (平均合併 12小時 56分鐘) (30 天內合併 52 個 PR)

描述

Hi all,

I am trying to use the ignores option in the configuration file to ignore a specific commit message.

Expected Behavior

Defining a function in the ignores array should ignore a specific commit message and allow it to pass if it is not conventional.

Current Behavior

echo "Initialize project using Create React App" | yarn commitlint
⧗   input: Initialize project using Create React App
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

Affected packages

  • cli
  • core
  • prompt
  • config-angular
module.exports = {
    extends: ["@commitlint/config-conventional"],
    ignores: [
        (commit) => commit === "Initialize project using Create React App",
    ],
};

Context

I would like to ignore this specific commit that is made by Create React App.

I am using a custom template that installs some Husky git hooks that uses commitlint during the bootstrap, prior to Create React App making the commit.

Currently, the commit is failing, and then Create React App deletes the .git directory.

Git commit not created Error: Command failed: git commit -m "Initialize project using Create React App"
    at checkExecSyncError (node:child_process:828:11)
    at execSync (node:child_process:899:15)
    at tryGitCommit (/Users/damienbutt/Projects/test-husky-postinstall-yarn/node_modules/react-scripts/scripts/init.js:62:5)
    at module.exports (/Users/damienbutt/Projects/test-husky-postinstall-yarn/node_modules/react-scripts/scripts/init.js:350:25)
    at [eval]:3:14
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at node:internal/process/execution:76:19
    at [eval]-wrapper:6:22 {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 71554,
  stdout: null,
  stderr: null
}
Removing .git directory...

It doesn't say it fails because of commitlint but I think that is because the execSync function is not set up to output to stdout. However, in testing, if I stop the Husky git hooks from being installed during the bootstrap of Create React App, it is able to successfully make the commit.

I would like to just ignore and allow this specific commit message from Create React App.

Your Environment

Executable Version
commitlint --version @commitlint/cli@16.2.4
git --version 2.36.0
node --version 16.15.0

貢獻者指南