commitizen / commitizen/cz-cli
Git-generated trailers are not preserved
- Vorherrschende Sprache
- JavaScript
- Sterne
- 17.5k
- Forks
- 566
- Ø Merge
- 8 Std. 16 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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
Beitragsleitfaden
Rechercherichtung
In der Issue wird keine Quelldatei und kein Test genannt. Beginne damit, den Pfad für `--hook` nachzuverfolgen, der `COMMIT_EDITMSG` umschreibt, und vergleiche ihn mit dem Verhalten von Git bei `-s` und `interpret-trailers`; als erledigt gilt es, wenn von Git erzeugte und bereits vorhandene Trailer den Hook überstehen, ohne dass eine Änderung nach dem Commit erforderlich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- git, javascript, shell
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100