This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""An epic held in memory, for do-epic's tests, held to contract.py like every backend."""
|
||||
import dataclasses
|
||||
|
||||
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit
|
||||
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit, unfit_label
|
||||
from failure import Failure
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class MemoryEpic:
|
||||
def add_label(self, key: str, label: str) -> None | Failure:
|
||||
if self.fails:
|
||||
return Failure(self.fails)
|
||||
if refused := unfit("-", (label,)):
|
||||
if refused := unfit_label(label):
|
||||
return refused
|
||||
child = next((issue for issue in self.issues if issue.key == key and issue.parent == self.epic_key), None)
|
||||
if child is None:
|
||||
|
||||
@@ -6,7 +6,7 @@ import typing
|
||||
from adf_codec.convert import adfs_to_markdown, markdown_to_adf, Refused
|
||||
from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
|
||||
from project_config.settings import Epic
|
||||
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit
|
||||
from do_epic.backend.protocol import EpicIssue, no_child, no_parent, unfit, unfit_label
|
||||
from failure import Failure
|
||||
from plan_store.jira_epic import ISSUE_KEY, ISSUE_TYPE, project_of, searched
|
||||
|
||||
@@ -80,7 +80,7 @@ class JiraEpic:
|
||||
authorization = basic_auth(self.env_file)
|
||||
if isinstance(authorization, Failure):
|
||||
return authorization
|
||||
if refused := unfit("-", (label,)):
|
||||
if refused := unfit_label(label):
|
||||
return refused
|
||||
above = self.parent_of(key, authorization, "to label it")
|
||||
if isinstance(above, Failure):
|
||||
|
||||
@@ -51,6 +51,11 @@ def unfit(summary: str, labels: tuple[str, ...]) -> Failure | None:
|
||||
"""Why no tracker can file an issue with this summary and these labels; None where one can."""
|
||||
if not summary.strip() or "\n" in summary:
|
||||
return Failure("the summary must be one line of text")
|
||||
return unfit_label(*labels)
|
||||
|
||||
|
||||
def unfit_label(*labels: str) -> Failure | None:
|
||||
"""Why no tracker can take one of these labels; None where one can."""
|
||||
if bad := next((label for label in labels if not LABEL.fullmatch(label)), None):
|
||||
return Failure(f"the label {bad!r} is empty or holds white space")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user