diff --git a/scripts/nexus-commit-msg-hook.sh b/scripts/nexus-commit-msg-hook.sh new file mode 100755 index 00000000..ab73bcf1 --- /dev/null +++ b/scripts/nexus-commit-msg-hook.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Nexus fork: enforce [nexus] prefix on all fork commits +# Allows upstream merge commits and rebase-generated commits through +MSG_FILE="$1" +FIRST_LINE=$(head -1 "$MSG_FILE") + +# Skip merge commits (git generates these automatically during rebase/merge) +if echo "$FIRST_LINE" | grep -qE "^Merge (branch|pull request|remote-tracking)"; then + exit 0 +fi + +# Skip fixup/squash commits (used during interactive rebase) +if echo "$FIRST_LINE" | grep -qE "^(fixup|squash)!"; then + exit 0 +fi + +# Enforce [nexus] prefix +if ! echo "$FIRST_LINE" | grep -qE "^\[nexus\]"; then + echo "ERROR: Commit message must start with [nexus]" + echo " Got: $FIRST_LINE" + echo " Example: [nexus] feat: add branding package" + exit 1 +fi