mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
Merge pull request #12237 from NixOS/reject-conflicts
Reject merge conflicts
This commit is contained in:
commit
01f5cf2c02
1 changed files with 21 additions and 0 deletions
|
@ -10,6 +10,27 @@
|
||||||
# https://flake.parts/options/git-hooks-nix#options
|
# https://flake.parts/options/git-hooks-nix#options
|
||||||
pre-commit.settings = {
|
pre-commit.settings = {
|
||||||
hooks = {
|
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 = {
|
clang-format = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# https://github.com/cachix/git-hooks.nix/pull/532
|
# https://github.com/cachix/git-hooks.nix/pull/532
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue