Skip to content

Different results from the same commit message between cli and actual commit #445

@b6pzeusbc54tvhw5jgpyw8pwz2x6gs

Description

Expected Behavior

Below two commands should be passed in my config. At least the same result should be output.

$ cat .git/COMMIT_EDITMSG | npx commitlint
$ git commit -m "chore(component,demo): bump"

Current Behavior

$ cat .git/COMMIT_EDITMSG | npx commitlint
⧗   input: chore(component,demo): bump
✔   found 0 problems, 0 warnings

Above command passed but below failed.

$ git commit -m "chore(component,demo): bump"
husky > commit-msg (node v8.12.0)
.git/COMMIT_EDITMSG
⧗   input:
chore(component,demo): bump

✖   scope may not be empty [scope-empty]
✖   message may not be empty [subject-empty]
✖   type may not be empty [type-empty]
✖   found 3 problems, 0 warnings
husky > commit-msg hook failed (add --no-verify to bypass)

Affected packages

  • [?] cli
  • [?] core
  • [?] prompt
  • [?] config-angular

Possible Solution

Steps to Reproduce (for bugs)

commitlint.config.js ```js ```

Context

Your Environment

package.json:

{
  "name": "root",
  "private": true,
  "devDependencies": {
    "husky": "^1.0.0-rc.14",
    "js-combinatorics": "^0.5.3",
    "lerna": "^3.3.1",
    "wsrun": "^2.2.1"
  },
  "workspaces": [
    "packages/*"
  ],
  "dependencies": {
    "@babel/cli": "^7.0.0",
    "@babel/core": "^7.0.1",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "@commitlint/cli": "^7.1.2",
    "@commitlint/config-conventional": "^7.1.2",
    "babel-eslint": "^9.0.0",
    "eslint": "^5.5.0",
    "eslint-plugin-react": "^7.11.1"
  },
  "husky": {
    "hooks": {
      "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
    }
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/b6pzeusbc54tvhw5jgpyw8pwz2x6gs/react-utterances.git"
  }
}
// commitlint.config.js
const Combinatorics = require('js-combinatorics')

const scopeList = ['root','component','demo']
const scopeEnumList = []

Combinatorics.power(scopeList).forEach( subset => {
  if( subset.length < 1 ) return

  const isAll = subset.length === scopeList.length
  scopeEnumList.push( isAll ? 'all' : subset.join(','))
})

module.exports = {
  rules: {
    'body-leading-blank': [1, 'always'],
    'footer-leading-blank': [1, 'always'],
    'header-max-length': [2, 'always', 72],
    'scope-case': [2, 'always', 'lower-case'],
    'scope-enum': [2, 'always', scopeEnumList],
    // scopeEnumList: [ 'root',  'component',  'root,component',  'demo',  'root,demo',  'component,demo',  'all' ]
    'scope-empty': [2, 'never'],
    'subject-case': [2, 'never', ['sentence-case','start-case','pascal-case','upper-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','chore','ci','docs','feat','fix','perf','refactor','revert','style','test','dx']],
  }
}

version:

$ npx commitlint --version
7.1.2
$ git --version
git version 2.15.2 (Apple Git-101.1)
$ node --version
v8.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions