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: Git submodule file priority on commit message edit #4038

Open
1 of 4 tasks
erayaydin opened this issue Apr 22, 2024 · 0 comments
Open
1 of 4 tasks

fix: Git submodule file priority on commit message edit #4038

erayaydin opened this issue Apr 22, 2024 · 0 comments

Comments

@erayaydin
Copy link

erayaydin commented Apr 22, 2024

Steps to Reproduce

  1. Create example folder structure
.
├── Folder1 (submodule)
│   ├── .git (file)
│   │   ...
│   ├── Project1
│   │   ├── .git (folder)
│   │   │   ├── COMMIT_EDITMSG
│   │   ...
  1. Install commitlint with commitizen integration
  2. 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.

https://github.com/conventional-changelog/commitlint/blob/master/%40commitlint/top-level/src/index.ts#L23-L24

commitlint --version

@commitlint/cli@19.2.2

git --version

git version 2.44.0

node --version

v21.7.3

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

No branches or pull requests

2 participants