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
10 changes: 10 additions & 0 deletions scripts/pre-commit.hook
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ if echo "$workspace" | grep -q "[一-龥]"; then
throw "The workspace path '$workspace' contains non-ASCII characters."
fi

# Check for merge conflict markers in staged changes.
# Assemble the conflict marker regex without embedding it directly.
CONFLICT_MARKERS=$(printf '%s|%s|%s' "<<<<<<<" "=======" ">>>>>>>")
# Get staged files that contain conflict markers, but exclude hook files.
CONFLICT_FILES=$(git diff --cached --name-only -G "${CONFLICT_MARKERS}" | \
grep -vE '(^|/)\.git/hooks/|(^|/)(pre-commit|commit-msg|prepare-commit-msg|pre-push)\.hook$')
if [ -n "${CONFLICT_FILES}" ]; then
throw "Conflict markers are still present in the following files:\n%s" ${CONFLICT_FILES}
fi

CLANG_FORMAT=$(which clang-format)
if [ $? -ne 0 ]; then
throw "clang-format not installed. Unable to check source file format policy."
Expand Down