From d061298da1d1c2bd7c750b54f9782bbe8babad5a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:37:25 +0200 Subject: [PATCH] ENH: add more excludes to `toml-sort` hook --- src/repoma/check_dev_files/toml.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/repoma/check_dev_files/toml.py b/src/repoma/check_dev_files/toml.py index 682a8d49..3e75d965 100644 --- a/src/repoma/check_dev_files/toml.py +++ b/src/repoma/check_dev_files/toml.py @@ -74,8 +74,14 @@ def _update_tomlsort_hook() -> None: repo="https://github.com/pappasam/toml-sort", hooks=[CommentedMap(id="toml-sort", args=["--in-place"])], ) + excludes = [] if glob("labels/*.toml"): - expected_hook["hooks"][0]["exclude"] = r"(?x)^(labels/.*\.toml)$" + excludes.append(r"labels/.*\.toml") + if glob("labels*.toml"): + excludes.append(r"labels.*\.toml") + if excludes: + excludes = sorted(excludes, key=str.lower) + expected_hook["hooks"][0]["exclude"] = "(?x)^(" + "|".join(excludes) + ")$" update_single_hook_precommit_repo(expected_hook)