fix: Git submodule file priority on commit message edit
erayaydin opened this issue · comments
Eray AYDIN commented
Steps to Reproduce
- Create example folder structure
.
├── Folder1 (submodule)
│ ├── .git (file)
│ │ ...
│ ├── Project1
│ │ ├── .git (folder)
│ │ │ ├── COMMIT_EDITMSG
│ │ ...
- Install commitlint with commitizen integration
- Run
yarn cm
(see Extra section)
Extra
.husky/commit-msg
#!/bin/sh
npx --no -- commitlint --edit $1
commitlint.config.ts
import type { UserConfig } from '@commitlint/types';
const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix']],
},
};
export default Configuration;
.czrc
{
"path": "@commitlint/cz-commitlint"
}
package.json
{
...
"scripts": {
...
"cm": "cz",
...
},
...
}
Current Behavior
Trying to use submodule instead of project git repository
file:///***/Project1/node_modules/@commitlint/cli/lib/cli.js:127
throw err;
^
Error: ENOTDIR: not a directory, open '/***/Folder1/.git/COMMIT_EDITMSG'
at async open (node:internal/fs/promises:637:25)
at async Object.readFile (node:internal/fs/promises:1246:14)
at async getEditCommit (file:///***/Project1/nextjs-boilerplate/node_modules/@commitlint/read/lib/get-edit-commit.js:13:22)
at async main (file:///***/Project1/nextjs-boilerplate/node_modules/@commitlint/cli/lib/cli.js:174:19) {
errno: -20,
code: 'ENOTDIR',
syscall: 'open',
path: '/***/Folder1/.git/COMMIT_EDITMSG'
}
Expected Behavior
Use Project1's git folder instead of Folder1 git file.
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
Add option to searchDotGit
function to pass these options to the findUp
. This way, we can exclude files and select only directories.
commitlint --version
@commitlint/cli@19.2.2
git --version
git version 2.44.0
node --version
v21.7.3