From aaa80e6e9b20e8a212ad6fa1a779a1f260ddb960 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 12 Jan 2025 13:50:55 +0100 Subject: [PATCH] Reject merge conflicts They're usually found by other checks, but docs would remain susceptible. (cherry picked from commit 29a1a21ce4448bc00c63d26a0c4238031c612cba) --- maintainers/flake-module.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/maintainers/flake-module.nix b/maintainers/flake-module.nix index fdb031302eb..57a1a9bfca4 100644 --- a/maintainers/flake-module.nix +++ b/maintainers/flake-module.nix @@ -10,6 +10,27 @@ # https://flake.parts/options/git-hooks-nix#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 = [