fix(husky): 修复 CHANGELOG 自动更新条件判断
- 简化 prepare-commit-msg 的条件判断 - 只跳过 merge 提交,其他情况都执行 - 修复了部分提交 CHANGELOG 没有自动更新的问题 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Showing
2 changed files
with
3 additions
and
12 deletions
| ... | @@ -25,18 +25,9 @@ NC='\033[0m' # No Color | ... | @@ -25,18 +25,9 @@ NC='\033[0m' # No Color |
| 25 | COMMIT_MSG_FILE=$1 | 25 | COMMIT_MSG_FILE=$1 |
| 26 | COMMIT_SOURCE=$2 # commit 来源:message/template/merge/squash等 | 26 | COMMIT_SOURCE=$2 # commit 来源:message/template/merge/squash等 |
| 27 | 27 | ||
| 28 | -# 只在正常的 commit 时执行,跳过 merge/rebase/amend | 28 | +# 只跳过 merge 提交,其他情况都执行 |
| 29 | -# amend 时 COMMIT_SOURCE 为空 | 29 | +# 这样可以确保无论使用何种方式提交(-m/-C/-c等),CHANGELOG 都会被更新 |
| 30 | -if [ "$COMMIT_SOURCE" = "message" ] || [ "$COMMIT_SOURCE" = "template" ] || [ "$COMMIT_SOURCE" = "" ]; then | 30 | +if [ "$COMMIT_SOURCE" != "merge" ]; then |
| 31 | - # 检查是否是 amend 操作(通过检查是否已有 commit) | ||
| 32 | - # 如果 HEAD 存在且不是初始提交,可能是 amend | ||
| 33 | - if git rev-parse HEAD >/dev/null 2>&1; then | ||
| 34 | - # 有 HEAD,检查是否是正在 amend | ||
| 35 | - # 简单的判断:如果已经有 commit 且当前没有在 rebase 等操作中 | ||
| 36 | - # 这里我们允许继续,因为关键在于 post-commit 的 --no-verify | ||
| 37 | - : | ||
| 38 | - fi | ||
| 39 | - | ||
| 40 | # 读取 commit message | 31 | # 读取 commit message |
| 41 | if [ -f "$COMMIT_MSG_FILE" ]; then | 32 | if [ -f "$COMMIT_MSG_FILE" ]; then |
| 42 | COMMIT_MSG=$(cat "$COMMIT_MSG_FILE") | 33 | COMMIT_MSG=$(cat "$COMMIT_MSG_FILE") | ... | ... |
This diff could not be displayed because it is too large.
-
Please register or login to post a comment