Skip to content

[BUG] First commit #242

Closed
Closed

Description

@jplu

describe your issue

Fails during the first commit of a just initiated repo when other hooks than check-message are activated as it seems to rely on the git log command that raises an error because the logs are empty.

For example, when the hook check-commit-signoff is activated:

Commit rejected.                                                  
                                                                  
Type commit_signoff check failed => fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
 
It doesn't match regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+>
Signed-off-by not found in latest commit
Suggest: run command `git commit -m "conventional commit message" --signoff`

commit-check version

0.9.7

.commit-check.yml

Activity

  1. added
    bug
    on Jul 6, 2025
  2. shenxianpeng commented on Jul 6, 2025

    @shenxianpeng
    Member

    Thanks for reporting the issue. It should be fixed in v0.9.8. Please feel free to reopen if the issue persists.

  3. jplu commented on Jul 9, 2025

    @jplu
    Author

    Thanks! Seems good except for some of the commands: check-branch, check-author-email and check-commit-signoff

    The signoff and email commands both fails with this error:

    check failed => Repo has no commits yet.
    
  4. shenxianpeng commented on Jul 9, 2025

    @shenxianpeng
    Member

    For check-commit-signoffc hook, it looks to work as expected.

    BUT it should be not failed instead of skip this hook

    (.venv) sxp@pc ~/c/test (main)> pre-commit try-repo  ../commit-check check-commit-signoff
    ===============================================================================
    Using config:
    ===============================================================================
    repos:
    -   repo: ../commit-check
        rev: 89249ec38cea1b9a168b69751b94ba45b7766ab7
        hooks:
        -   id: check-commit-signoff
    ===============================================================================
    [INFO] Initializing environment for ../commit-check.
    [INFO] Installing environment for ../commit-check.
    [INFO] Once installed this environment will be reused.
    [INFO] This may take a few minutes...
    check committer signoff..................................................Failed
    - hook id: check-commit-signoff
    - exit code: 1
    
    Commit rejected by Commit-Check.
    
      (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)    (c).-.(c)
       / ._. \      / ._. \      / ._. \      / ._. \      / ._. \
     __\( C )/__  __\( H )/__  __\( E )/__  __\( C )/__  __\( K )/__
    (_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
       || E ||      || R ||      || R ||      || O ||      || R ||
     _.' '-' '._  _.' '-' '._  _.' '-' '._  _.' '-' '._  _.' '-' '._
    (.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
     `-´     `-´  `-´     `-´  `-´     `-´  `-´     `-´  `-´     `-´
    
    Commit rejected.
    
    Type commit_signoff check failed => Repo has no commits yet.
    It doesn't match regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+>
    Signed-off-by not found in latest commit
    Suggest: run command `git commit -m "conventional commit message" --signoff`
    
    (.venv) sxp@pc ~/c/test (main) [0|1]> git log
    fatal: your current branch 'main' does not have any commits yet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions