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

Input argument required with git commit -m "..." #118

Open
georgezavitsanos opened this issue Oct 18, 2024 · 5 comments
Open

Input argument required with git commit -m "..." #118

georgezavitsanos opened this issue Oct 18, 2024 · 5 comments
Labels
question Further information is requested

Comments

@georgezavitsanos
Copy link

georgezavitsanos commented Oct 18, 2024

Hello, I have configured conventional-pre-commit from .pre-commit-config.yaml file,

  - repo: https://github.com/compilerla/conventional-pre-commit
    rev: v3.6.0
    hooks:
      - id: conventional-pre-commit
        stages: [commit-msg]
        args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test]

However, with git commit -m "This is a comment". , I get,

Conventional Commit......................................................Failed
- hook id: conventional-pre-commit
- exit code: 1

usage: conventional-pre-commit
       [-h]
       [--no-color]
       [--force-scope]
       [--scopes SCOPES]
       [--strict]
       [--verbose]
       [types ...]
       input
conventional-pre-commit: error: the following arguments are required: input

Please for your advise.

@georgezavitsanos
Copy link
Author

georgezavitsanos commented Oct 18, 2024

Found a workaround with:

  - repo: https://github.com/compilerla/conventional-pre-commit
    rev: v3.6.0
    hooks:
      - id: conventional-pre-commit
        stages: [commit-msg]
        args: [".git/COMMIT_EDITMSG"]

@thekaveman
Copy link
Member

Hi @georgezavitsanos, can you please share the output of pre-commit -V and the complete .pre-commit-config.yaml you're using and/or a link to your repo if it is open source?

I'm not able to reproduce this. The commit message should be passed automatically via pre-commit for the commit-msg stage.

@georgezavitsanos
Copy link
Author

georgezavitsanos commented Oct 21, 2024

Hello!
My .pre-commit-config.yaml

repos:
  - repo: https://github.com/ambv/black
    rev: 24.10.0
    hooks:
      - id: black
        language_version: python3.10
  - repo: https://github.com/pycqa/flake8
    rev: 7.1.1
    hooks:
      - id: flake8
        additional_dependencies: []
        args: []
  - repo: https://github.com/PyCQA/isort
    rev: 5.13.2
    hooks:
      - id: isort
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.11.2
    hooks:
      - id: mypy
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: end-of-file-fixer
      - id: trailing-whitespace
      - id: check-yaml
  - repo: https://github.com/compilerla/conventional-pre-commit
    rev: v3.6.0
    hooks:
      - id: conventional-pre-commit
        stages: [commit-msg]
        args: [".git/COMMIT_EDITMSG", "--verbose"]

and pre-commit -V :

pre-commit 4.0.1

Unfortunately, the repo is not open-source, so I cannot share it.

The above configuration works for me. Without ".git/COMMIT_EDITMSG" in args list, it does not.

@thekaveman
Copy link
Member

Thanks @georgezavitsanos. One more thought:

In our .pre-commit-config.yaml files, we add this additional config at the top:

default_install_hook_types:
  - pre-commit
  - commit-msg

So that when we run pre-commit install --install-hooks, hooks for these stages are installed by default. Otherwise, commit-msg is not installed by default, see https://pre-commit.com/#top_level-default_install_hook_types.

This is probably related to #104 in that we need better docs here for the initial setup.

Can you try removing the .git/COMMIT_EDITMSG arg, adding the above to your config file and reinstalling and/or try running
pre-commit install --hook-type commit-msg, and see if it works for you?

@thekaveman thekaveman added the question Further information is requested label Oct 21, 2024
@georgezavitsanos
Copy link
Author

Thanks for your reply.
Unfortunately, it does not work. I get again


Conventional Commit......................................................Failed
- hook id: conventional-pre-commit
- exit code: 1

usage: conventional-pre-commit
       [-h]
       [--no-color]
       [--force-scope]
       [--scopes SCOPES]
       [--strict]
       [--verbose]
       [types ...]
       input
conventional-pre-commit: error: the following arguments are required: input

Anyway, I will use my work around. Thanks!

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

No branches or pull requests

2 participants