1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

Reject merge conflicts

They're usually found by other checks, but docs would remain
susceptible.

(cherry picked from commit 29a1a21ce4)
This commit is contained in:
Robert Hensing 2025-01-12 13:50:55 +01:00 committed by Mergify
parent c803fe0785
commit 10438e6cfd

View file

@ -10,6 +10,27 @@
# https://flake.parts/options/pre-commit-hooks-nix.html#options
pre-commit.settings = {
hooks = {
# Conflicts are usually found by other checks, but not those in docs,
# and potentially other places.
check-merge-conflicts.enable = true;
# built-in check-merge-conflicts seems ineffective against those produced by mergify backports
check-merge-conflicts-2 = {
enable = true;
entry = "${pkgs.writeScript "check-merge-conflicts" ''
#!${pkgs.runtimeShell}
conflicts=false
for file in "$@"; do
if grep --with-filename --line-number -E '^>>>>>>> ' -- "$file"; then
conflicts=true
fi
done
if $conflicts; then
echo "ERROR: found merge/patch conflicts in files"
exit 1
fi
touch $out
''}";
};
clang-format = {
enable = true;
excludes = [