Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: remove ci.skip if empty #485

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading