Skip to content
Merged
Changes from all commits
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
29 changes: 29 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
#!/bin/sh
[ -n "$CI" ] && exit 0

# Check for merge conflict markers
# This hook prevents commits that contain unresolved merge conflicts.
# It checks the staged changes for common conflict markers
# (e.g., <<<<<<<, =======, >>>>>>>) and blocks the commit if any are found.

# This file will always fail since it contains the conflict markers pattern,
# We will still check this file for conflict markers to prevent committing
# unresolved conflicts.

# In order to intentionallyupdate this file, create a commit with only this
# file and skip the pre-commit hook
# Usage:
# - Run with env var: SKIP_CONFLICT_CHECK=1 git commit
if [ "$SKIP_CONFLICT_CHECK" != "1" ]; then
conflicts=$(git diff --cached --name-only | xargs grep -H -n -E "<{7} HEAD|={7}|>{7} " 2>/dev/null)
if [ ! -z "$conflicts" ]; then
echo "Error: Merge conflict markers found in staged files."
echo "\nConflicts found:"
echo "$conflicts" | while IFS= read -r line; do
echo " → $(echo "$line" | sed 's/\([0-9]\):\([<>=]\)/\1 \2/')"
done
echo "\nPlease resolve all merge conflicts before committing."
exit 1
fi
fi

exit 0