Set a Jira issue's blocked-by links from todo-item edit --blocked-by on an issue the loop filed #576

Merged
lilleman merged 10 commits from item-389 into main 2026-11-17 06:57:52 +01:00
2 changed files with 7 additions and 2 deletions
Showing only changes of commit c1b278d2ea - Show all commits
+2 -2
View File
@@ -501,14 +501,14 @@ def missing_blocker(blockers: tuple[str, ...], held: set[object], label: str) ->
def blocking_loop(answered: list[object], issue: Issue, blockers: tuple[str, ...], label: str) -> Failure | None:
"""A Failure where issue, once blocked by blockers, would block itself through the items its blockers wait for, and none of them could be taken; None otherwise. A loop the plan already holds without issue isn't this edit's."""
"""A Failure where issue, once blocked by blockers, which the caller has checked are open children, would block itself through the items its blockers wait for, and none of them could be taken; None otherwise. A loop the plan already holds without issue isn't this edit's."""
issues = {found.key: found for raw in answered if isinstance(found := issue_of(raw), Issue)}
waits_for = {found.key: found.blockers for found in issues.values()} | {issue.key: blockers}
reached: set[str] = set()
frontier = set(blockers)
while frontier:
reached |= frontier
frontier = {blocker for key in frontier for blocker in waits_for.get(key, ()) if blocker in issues} - reached
frontier = {blocker for key in frontier for blocker in waits_for[key] if blocker in issues} - reached
return Failure(f"{label}: item {issue.number} would be blocked by itself through {', '.join(str(number(key)) for key in sorted(reached - {issue.key}, key=number))}; drop one of the blockers") if issue.key in reached else None
+5
View File
@@ -679,6 +679,11 @@ class Editing(unittest.TestCase):
self.assertEqual(self.edit(34, {"L": "2", "Blocked by": "36"}), Failure("jira:https://acme.atlassian.net/browse/ABC-12: item 34 would be blocked by itself through 35, 36; drop one of the blockers"))
self.assertEqual(self.writes(), [])
def test_the_loop_names_its_items_by_number_not_by_key(self):
self.open += [issue("ABC-9", scores=PROPERTY, blocked_by=("ABC-10",)), issue("ABC-10", scores=PROPERTY, blocked_by=("ABC-34",))]
failure = self.edit(34, {"Blocked by": "9"})
self.assertTrue(failure.reason.endswith("through 9, 10; drop one of the blockers")) # type: ignore[union-attr]
def test_a_loop_the_plan_holds_without_the_issue_does_not_stop_its_edit(self):
self.open[1] = issue("ABC-35", scores=PROPERTY, blocked_by=("ABC-36",))
self.open[2] = issue("ABC-36", scores=PROPERTY, blocked_by=("ABC-35",))