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

Bug in Argument Parsing for conventional-pre-commit Hook Configuration #129

Open
jg197 opened this issue Feb 25, 2025 · 1 comment
Open

Comments

@jg197
Copy link

jg197 commented Feb 25, 2025

Hi,

When using the args field to pass command-line arguments in the pre-commit hook configuration for conventional-pre-commit, the arguments are not being parsed correctly. For example, the configuration:

- repo: https://github.com/compilerla/conventional-pre-commit
  rev: v4.0.0
  hooks:
    - id: conventional-pre-commit
      stages: [commit-msg]
      args: [--verbose, --force-scope, --scopes api]

fails to correctly interpret the arguments. However, directly specifying the CLI command via the entry field works as intended:

- repo: https://github.com/compilerla/conventional-pre-commit
  rev: v4.0.0
  hooks:
    - id: conventional-pre-commit
      stages: [commit-msg]
      entry: conventional-pre-commit --verbose --force-scope --scopes api .git/COMMIT_EDITMSG

This was true for the commit message:
fix(foobar): test commit rejected as expected only when specifying the CLI command via the entry field.

I believe the root cause is how the args are being handled. I don't think there are any tests that cover usage of the args field, and instead existing tests call the module directly.

Thanks!

@maikol-solis
Copy link

maikol-solis commented Apr 5, 2025

Today I had the same issue as you, and this format worked for me

repos:
  - repo: https://github.com/compilerla/conventional-pre-commit
    rev: v4.0.0
    hooks:
      - id: conventional-pre-commit
        stages: [commit-msg]
        args:
          [
            "--verbose",
            "--scope",
            "data,src,lib,munge,docs,config",
            "feat",
            "fix",
            "refactor",
            "perf",
            "style",
            "test",
            "docs",
            "build",
            "chore",
            "ci"
          ]

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

No branches or pull requests

2 participants