diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index d755f410..04321f4d 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -1442,7 +1442,12 @@ def _mergify_timeout_detail( ) detail = f"still queued in {queue}. {location}" if state.unmet_conditions: - detail += ". Unmet candidate conditions: " + "; ".join(state.unmet_conditions) + labels = [label.encode() for label in state.unmet_conditions[:4]] + shown = [label[:160].decode(errors="ignore") + ("…" if len(label) > 160 else "") + for label in labels] + detail += ". Unmet candidate conditions: " + "; ".join(shown) + if omitted := len(state.unmet_conditions) - len(shown): + detail += f"; {omitted} more" return detail diff --git a/tests/test_cli.py b/tests/test_cli.py index 404c4616..9acdf464 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4453,22 +4453,22 @@ def test_mergify_reports_current_queue_attempt(wt, gh, capsys, monkeypatch, conf assert (f"{URL}#issuecomment-43" in out) is (kind == "current") -@pytest.mark.parametrize("result", ["blocking", "neutral", "skipped", None]) +@pytest.mark.parametrize("result", ["blocking", "neutral", "skipped", None, "long", "many"]) def test_mergify_timeout_reports_evaluated_candidate_conditions(wt, gh, capsys, monkeypatch, result): head = commit_mergify_configuration(wt) arm_approved_ready_pr(gh, head, wt, isDraft=False) monkeypatch.setattr(mergify, "configured", lambda *_: True) - monkeypatch.setattr(mergify, "markers", lambda *_: (True, False)) - monkeypatch.setattr(mergify, "mark_confirmed", lambda *_: None) - responses = iter([None, MERGIFY_QUEUE_FIXTURE["candidate_responses"][result or "missing"]]) - monkeypatch.setattr(mergify, "api_get", lambda *_: next(responses)) - + monkeypatch.setattr(mergify, "markers", lambda *_: (True, True)) + payload = MERGIFY_QUEUE_FIXTURE["candidate_responses"]["blocking" if result in {"long", "many"} else result or "missing"] + if extra := {"long": 1, "many": 30}.get(result, 0): + conditions = payload["mergeability_check"]["conditions_evaluation"] + monkeypatch.setitem(conditions, "subconditions", conditions["subconditions"] + [{"match": False, "label": "界" * 3000}] * extra) + monkeypatch.setattr(mergify, "api_get", lambda *_: payload) code, out, err = run(capsys, "merge", "--wait=0") - - assert (code, err) == (3, "") - assert f"https://github.com/{REPO}/pull/42" in out - assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) is (result == "blocking") + assert (code, err) == (3, "") and f"https://github.com/{REPO}/pull/42" in out + assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) == (result in {"blocking", "long", "many"}) assert "failed" not in out and "check-success = checks" not in out + assert len(out.encode()) < 2048 and ("27 more" in out) == (extra == 30) @pytest.mark.parametrize("queue_state", ["unsafe", "error", "safe", "becomes_unsafe"])