refactor(util): make render_diff generic (caller supplies side titles); move to root util
tracker-policy-pr / check-pr (pull_request) Successful in 8s
test / integration-docker (pull_request) Successful in 36s
test / unit (pull_request) Successful in 43s
lint / lint (push) Successful in 56s
test / integration-firecracker (pull_request) Successful in 3m27s
test / coverage (pull_request) Successful in 21s
test / publish-infra (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 8s
test / integration-docker (pull_request) Successful in 36s
test / unit (pull_request) Successful in 43s
lint / lint (push) Successful in 56s
test / integration-firecracker (pull_request) Successful in 3m27s
test / coverage (pull_request) Successful in 21s
test / publish-infra (pull_request) Has been skipped
Generalize render_diff so it isn't supervise-flavored: the "(current)" / "(proposed)" side titles are no longer baked in — callers pass `before_title` and `after_label` (required). Move it from orchestrator/supervisor/util.py to the base bot_bottle.util alongside sha256_hex, and delete the now-empty supervisor/util.py. The supervise callsite (Orchestrator.supervise_respond) assigns before_title="current", after_label="proposed"; the facade no longer re-exports render_diff (callers import from bot_bottle.util). Behavior at the supervise callsite is unchanged. Full unit suite green (2243). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
|
||||
from bot_bottle.orchestrator import supervisor as supervise
|
||||
from bot_bottle.paths import host_db_path
|
||||
from bot_bottle.util import sha256_hex
|
||||
from bot_bottle.util import render_diff, sha256_hex
|
||||
from tests.unit import use_bottle_root
|
||||
from bot_bottle.store.audit_store import AuditStore
|
||||
from bot_bottle.orchestrator.store.queue_store import QueueStore
|
||||
@@ -21,7 +21,6 @@ from bot_bottle.orchestrator.supervisor import (
|
||||
Supervisor,
|
||||
TOOL_EGRESS_ALLOW,
|
||||
TOOL_GITLEAKS_ALLOW,
|
||||
render_diff,
|
||||
)
|
||||
|
||||
_SV = Supervisor()
|
||||
@@ -249,10 +248,10 @@ class TestAuditLog(unittest.TestCase):
|
||||
|
||||
class TestDiffAndHash(unittest.TestCase):
|
||||
def test_render_diff_returns_empty_when_unchanged(self):
|
||||
self.assertEqual("", render_diff("a\nb\n", "a\nb\n"))
|
||||
self.assertEqual("", render_diff("a\nb\n", "a\nb\n", before_title="current", after_label="proposed"))
|
||||
|
||||
def test_render_diff_shows_changes(self):
|
||||
diff = render_diff("a\nb\nc\n", "a\nB\nc\n", label="routes.yaml")
|
||||
diff = render_diff("a\nb\nc\n", "a\nB\nc\n", label="routes.yaml", before_title="current", after_label="proposed")
|
||||
self.assertIn("routes.yaml (current)", diff)
|
||||
self.assertIn("routes.yaml (proposed)", diff)
|
||||
self.assertIn("-b", diff)
|
||||
|
||||
Reference in New Issue
Block a user