Answer product-owner round 2: 1 🔴, 1 🟡 (0 misread); take a workflow's one done transition whatever the config names, move a split item to done with its last sub-task, count the finished chunk as done in the next start, and read a parent and status together

This commit is contained in:
2026-11-19 00:08:28 +01:00
parent 001b3315bf
commit 7d458159cc
4 changed files with 77 additions and 20 deletions
+5 -5
View File
@@ -154,15 +154,15 @@ class JiraEpic:
def parent_of(self, key: str, authorization: str, why: str) -> str | None | Failure:
"""The key of key's parent issue; None where key isn't an issue key or has no parent. A failed read says "cannot read <key> <why>"."""
placed = self.placed(key, authorization, why, "parent")
placed = self.placed(key, authorization, why)
return placed if isinstance(placed, Failure) else placed[0]
def placed(self, key: str, authorization: str, why: str, asked: str = "parent,status") -> tuple[str | None, bool] | Failure:
"""The key of key's parent issue, None where key isn't an issue key or has no parent, and whether key's own status is a done one; asked names the fields to read, and leaving out `status` makes key read as not done. A failed read says "cannot read <key> <why>"."""
def placed(self, key: str, authorization: str, why: str) -> tuple[str | None, bool] | Failure:
"""The key of key's parent issue, None where key isn't an issue key or has no parent, and whether key's own status is a done one. A failed read says "cannot read <key> <why>"."""
if not ISSUE_KEY.fullmatch(key):
return None, False
# A search may not show an issue filed a moment ago, so the issue is asked for by its key.
answered = self.http("GET", f"{self.epic.site}/rest/api/3/issue/{key}?fields={asked}", authorization, None)
answered = self.http("GET", f"{self.epic.site}/rest/api/3/issue/{key}?fields=parent,status", authorization, None)
if isinstance(answered, Failure):
return Failure(f"cannot read {key} {why}: {answered.reason}")
fields = answered.get("fields") if isinstance(answered, dict) else None
@@ -217,7 +217,7 @@ def done_transition(offered: object, key: str, named: str | None) -> str | Failu
if not isinstance(raw, list) or len(found) != len(raw):
return Failure(f"Jira answered {key}'s transitions in a shape other than the one it documents")
closing = [(id_, name, status) for id_, name, status, category in found if category == DONE]
chosen = [move for move in closing if named is None or move[1] == named]
chosen = closing if len(closing) == 1 else [move for move in closing if move[1] == named]
if len(chosen) == 1:
return chosen[0][0]
listed = " and ".join(f"{name!r} to {status!r}" for _, name, status in closing)