Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/operations_center/entrypoints/custodian_sweep/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ def _emit(
title = f"[{sweep.repo_key}] custodian sweep: {sweep.total} findings"
body = _render_body(sweep, deltas)
existing = existing_tasks.get(sweep.repo_key)
if sweep.error is None and sweep.total == 0:
return "skipped-zero-findings" if not dry_run else "would-skip-zero-findings"
if dry_run:
return "would-comment" if existing else "would-create"
if existing:
Expand Down
38 changes: 38 additions & 0 deletions tests/test_custodian_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
_DEDUP_LABEL_PREFIX,
_delta,
_discover_targets,
_emit,
_find_open_sweep_task,
_index_open_sweep_tasks,
_render_body,
Expand Down Expand Up @@ -121,6 +122,43 @@ def test_index_open_sweep_tasks_maps_repo_key_to_issue() -> None:
}


def test_emit_skips_zero_finding_repo_without_plane_calls() -> None:
calls: list[tuple[str, object]] = []

plane = SimpleNamespace(
comment_issue=lambda issue_id, body: calls.append(("comment", issue_id, body)),
create_issue=lambda **kwargs: calls.append(("create", kwargs)),
)

action = _emit(
_RepoSweep(repo_key="Demo", envelope=_envelope()),
{},
plane,
existing_tasks={},
dry_run=False,
)

assert action == "skipped-zero-findings"
assert calls == []


def test_emit_dry_run_reports_zero_finding_skip() -> None:
plane = SimpleNamespace(
comment_issue=lambda issue_id, body: None,
create_issue=lambda **kwargs: None,
)

action = _emit(
_RepoSweep(repo_key="Demo", envelope=_envelope()),
{},
plane,
existing_tasks={},
dry_run=True,
)

assert action == "would-skip-zero-findings"


def test_discover_targets_filters_to_repos_with_custodian_yaml(tmp_path: Path) -> None:
has_yaml = tmp_path / "WithYaml"
has_yaml.mkdir()
Expand Down
Loading