commitizen / commitizen/cz-cli

Git-generated trailers are not preserved

Đang mở
#820 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
17.5k
Fork
566
Merge trung bình
8 giờ 16 phút
Pull request đã merge (30 ngày)
1

Mô tả

Commitizen's `--hook` option truncates the `COMMIT_EDITMSG` file. This wipes the `Signed-off-by` trailer generated by Git's `-s` flag, as well as any other trailers that might have been there before running Commitizen, and forces us to amend our commits after the fact.

We have a temporary workaround in our hook for this, which might offer some insight:

```sh
#!/bin/bash

file="$1"
type="$2"

if [ -z "$type" ]; then # only run on new commits
#
# Save any commit message trailers generated by Git.
#

trailers=$(git interpret-trailers --parse "$file")

#
# Execute the Commitizen hook.
#

(exec < "/dev/tty" && npx --no-install git-cz --hook) || true

#
# Restore any trailers that Commitizen might have overwritten.
#

printf "\n" >> "$file"

while IFS= read -r trailer; do
git interpret-trailers --in-place --trailer "$trailer" "$file"
done <<< "$trailers"
fi
```

Version: cz-cli@4.2.2, cz-conventional-changelog@3.3.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.