Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

# ANSI colors
RED="\033[0;31m"
YELLOW="\033[0;33m"
CYAN="\033[0;36m"
GREEN="\033[0;32m"
RESET="\033[0m"

commit_msg_file=$1

# Guard: ensure commit message file exists
Expand All @@ -11,7 +18,7 @@ if [ -z "$commit_msg_file" ] || [ ! -f "$commit_msg_file" ]; then
fi

if ! grep -q "Signed-off-by:" "$commit_msg_file"; then
echo "Commit message missing Signed-off-by line"
echo "Use: git commit -s ..."
echo "${RED} Commit message missing Signed-off-by line ${RESET}"
echo "${GREEN} Use: git commit -s ... ${RESET}"
exit 1
fi
21 changes: 19 additions & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,30 @@ echo "🔒 Checking commit signatures..."
while read local_ref local_sha remote_ref remote_sha; do
# Determine range of commits
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
range="$local_sha"
current_branch=$(git rev-parse --abbrev-ref HEAD)
base_branch=$(git for-each-ref --format='%(refname:short)' refs/heads/ \
| grep -v "^${current_branch}$" \
| while read other_branch; do
merge_base=$(git merge-base "$current_branch" "$other_branch")
echo "$(git rev-list --count ${merge_base}..${current_branch}) $other_branch"
done \
| sort -n \
| head -n1 \
| awk '{print $2}')

if [ -z "$base_branch" ]; then
echo "⚠️ Base branch not found — defaulting to 'main'"
base_branch=${default_branch:-main}
fi
base_commit=$(git merge-base "$base_branch" "$current_branch")
range="$base_commit..$local_sha"
else
range="$remote_sha..$local_sha"
fi

unsigned_commits=""

echo "commit range ${range}"
# Loop through each commit in range
for commit in $(git rev-list $range); do
# Skip merge commits
Expand Down Expand Up @@ -88,4 +105,4 @@ while read local_ref local_sha remote_ref remote_sha; do
fi
done

echo "${GREEN}✅ No unsigned commits found${RESET}"
echo "${GREEN}✅ No unsigned commits found${RESET}"