Skip to content

[BUG] check-branch not working when first commit #249

@jplu

Description

@jplu

describe your issue

The command check-branch is not working when the pre-commit runs over the first commit.

How to replicate. Here how looks like my .pre-commit-config.yaml

default_install_hook_types: [pre-commit, prepare-commit-msg]

repos:
  - repo: https://github.com/commit-check/commit-check
    rev: v0.9.8
    hooks:
      -   id: check-branch

Minimum commands to run (the pre-commit file is assumed to be created already):

mkdir test
cd test
git init
cp ../.pre-commit-config.yaml .
git add -A
git commit -m "chore: init repo"

Result:

check branch naming......................................................Failed
- hook id: check-branch
- 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 branch 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: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)
Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/
Suggest: run command `git checkout -b type/branch_name`

commit-check version

0.9.8

.commit-check.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions