From 3e7d791061be477b20a9d4e1f57872a51a392a57 Mon Sep 17 00:00:00 2001
From: Daniel Baker <daniel.n.baker@gmail.com>
Date: Sat, 14 Dec 2024 23:55:08 -0800
Subject: [PATCH] bugfix: remove before/after options from config json file

A recent commit to add ordering priority to the hooks introduced new
keys into the pre-commit JSON config file. These keys should not be
there are they are not keys pre-commit is aware of and produce warning
messages. e.g.:

```
[WARNING] Unexpected key(s) present on local => treefmt: after, before
```

This commit fixes it by filter out all keys with names `before` or
`after`, in Nix, before writing the configuration to file.

Fixes https://github.com/cachix/git-hooks.nix/issues/112
---
 modules/pre-commit.nix | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/pre-commit.nix b/modules/pre-commit.nix
index 8ad81104..a9b2b2ba 100644
--- a/modules/pre-commit.nix
+++ b/modules/pre-commit.nix
@@ -9,6 +9,7 @@ let
     mapAttrsToList
     mkOption
     types
+    removeAttrs
     remove
     ;
 
@@ -43,8 +44,15 @@ let
           )
           enabledHooks
         );
+      cleanedHooks = builtins.map (
+        hook:
+        removeAttrs hook [
+          "before"
+          "after"
+        ]
+      ) sortedHooks.result;
     in
-    sortedHooks.result;
+    cleanedHooks;
 
   configFile =
     performAssertions (