mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-05 22:15:46 +01:00
improve: nix flakebox fmt
This commit is contained in:
23
misc/git-hooks/commit-msg
Executable file
23
misc/git-hooks/commit-msg
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# Sanitize file first, by removing leading lines that are empty or start with a hash,
|
||||
# as `convco` currently does not do it automatically (but git will)
|
||||
# TODO: next release of convco should be able to do it automatically
|
||||
MESSAGE="$(
|
||||
while read -r line ; do
|
||||
# skip any initial comments (possibly from previous run)
|
||||
if [ -z "${body_detected:-}" ] && { [[ "$line" =~ ^#.*$ ]] || [ "$line" == "" ]; }; then
|
||||
continue
|
||||
fi
|
||||
body_detected="true"
|
||||
|
||||
echo "$line"
|
||||
done < "$1"
|
||||
)"
|
||||
|
||||
# convco fails on fixup!, so remove fixup! prefix
|
||||
MESSAGE="${MESSAGE#fixup! }"
|
||||
if ! convco check --from-stdin <<<"$MESSAGE" ; then
|
||||
>&2 echo "Please follow conventional commits(https://www.conventionalcommits.org)"
|
||||
>&2 echo "Use git recommit <args> to fix your commit"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user