Skip to content

Commit

Permalink
FIX: remove ci.skip if empty (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Jan 9, 2025
1 parent 971f8d2 commit 05e2ada
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/compwa_policy/check_dev_files/precommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,18 @@ def _update_precommit_ci_skip(precommit: ModifiablePrecommit) -> None:
local_hooks = get_local_hooks(precommit.document)
non_functional_hooks = get_non_functional_hooks(precommit.document)
expected_skips = sorted(set(non_functional_hooks) | set(local_hooks))
if not expected_skips and "skip" in precommit_ci:
del precommit_ci["skip"]
msg = "Removed redundant ci.skip section"
precommit.changelog.append(msg)
return
existing_skips = precommit_ci.get("skip")
if existing_skips != expected_skips:
if expected_skips and existing_skips != expected_skips:
precommit_ci["skip"] = sorted(expected_skips)
yaml_config = cast("CommentedMap", precommit.document)
yaml_config.yaml_set_comment_before_after_key("repos", before="\n")
msg = "Updated ci.skip section"
precommit.changelog.append(msg)
if not expected_skips and existing_skips:
del precommit_ci["skip"]
msg = "Removed redundant ci.skip section"
precommit.changelog.append(msg)


def get_local_hooks(config: PrecommitConfig) -> list[str]:
Expand Down

0 comments on commit 05e2ada

Please sign in to comment.