commitizen / commitizen/cz-cli

commitizen produces empty commit message after answering prompts

未关闭
#967 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
JavaScript
星标
17.5k
派生
566
平均合并
8 小时 16 分钟
30 天内合并 PR
1

描述

### Description

We set up `cz` as a husky pre-commit hook but when we go through the prompts via `git commit` it produces an empty commit message in `vim`.

These commands were executed to set it up:

```
npm install --save-dev commitizen
npx commitizen init cz-conventional-changelog --save-dev --save-exact
npx husky-init && npm install
```

Our `.husky/prepare-commit-msg`:

```
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

echo '[husky] Running commitizen for prepare-commit-msg hook...'
exec < /dev/tty && npx cz --hook || true
```

### Steps to reproduce

1. Execute `git commit`.
2. Answer the cz prompts.
3. A vim editor is opened.

### Current behavior

The vim editor has an empty commit message and commitizen errors out due to an empty commit message.

### Desired behavior

commitizen produces a commit message using information entered in prompts.

### Screenshots

```
git commit
[husky] Running commitizen for prepare-commit-msg hook...
cz-cli@4.3.0, cz-customizable@7.0.0

All lines except first will be wrapped after 100 characters.
? Select the type of change that you're committing: chore: Changes that don't modify src or test files
?
Denote the SCOPE of this change (optional): empty
? Write a SHORT, IMPERATIVE description of the change:
cz message prompt tweak
? Provide a LONGER description of the change (optional). Use "|" to break new line:
false
? List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:

str.match is not a function
Aborting commit due to empty commit message.
```

![image](https://user-images.githubusercontent.com/179807/218177263-80a59267-dff1-452a-b8a4-ace39f0ae9a6.png)

### Environment

cz-cli@4.3.0
cz-customizable@7.0.0

贡献指南

打开贡献指南

调研方向

Start with the .husky/prepare-commit-msg hook and reproduce the issue by running git commit, answering the commitizen prompts, and observing the Vim editor and str.match error. Trace how the prompted values are passed into the commit message; done means the entered prompt data produces a non-empty commit message without the error.

由索引模型根据 Issue 内容生成。

评估

技术栈
git, javascript, node.js
领域
cli, tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。