Improvement(/Bug): Missing shebang causes problems for cli when used with pre-commit
See original GitHub issueExpected Behavior
pre-commit
is a git hook framework which also supports commit-msg
hooks. There is a gh-repo which intents to add pre-commit
support to commitlint
.
After adding this to .pre-commit-config.yaml
:
repos:
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: a330c424e7903ebbe62b57154456d80d5fbc2b11 # frozen: v4.0.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-angular']
and installing the hook
$ pre-commit install -t commit-msg
it should run on every commit and abort the commit if commitlint
does not give its ok.
Current Behavior
Currently I get an error:
$ git commit -m "test commit"
commitlint...............................................................Failed
- hook id: commitlint
- exit code: 1
[Errno 8] Exec format error: '/home/krys/.cache/pre-commit/repowovky9t0/node_env-system/bin/commitlint'
*** Exit Code: 1 ***
After some googlin’ I found out that a missing shebang could be the cause. And indeed the mentioned file does not have one, starting with:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
...
Affected packages
- cli
- core
- prompt
- config-angular
Possible Solution
The aforementioned repo also supports commitlint-travis
as a hook. After looking into the commitlint-travis
file in the bin
directory mentioned in the error I found a shebang: #!/usr/bin/env node
.
As I don’t have any knowledge on node or JS/TS I could not backtrack those files into the source code as the files seem to differ from the installed ones.
Would it be possible to add a shebang to the corresponding file for commitlint-cli as it is for commitlint-travis?
Steps to Reproduce (for bugs)
- You need to have python installed
- Install pre-commit:
curl https://pre-commit.com/install-local.py | python -
- create a git repo
- create a
.pre-commit-config.yaml
file with the content from above - install hook locally
pre-commiit install -t commit-msg
- try to commit:
git commit -a -m "test"
Context
Your Environment
Executable | Version |
---|---|
commitlint --version |
11.0.0 |
git --version |
2.17.1 |
node --version |
v14.15.0 |
OS: linux mint 19.3
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (2 by maintainers)
Top GitHub Comments
That was it, funny how that flew under the radar this long. Thanks a lot @AdeAttwood
@ChristianMurphy sorry for tagging you. Tried to tag @Cielquan 😛
@Cielquan and @tkcranny thanks for the info.
We’ll have a look.