File findings, release reviews and added items as the issue types the settings name, and refuse a type the Jira project lacks

This commit is contained in:
Lilleman
2026-11-20 11:31:44 +01:00
parent 88fee92dcb
commit 34328b11b9
15 changed files with 179 additions and 30 deletions
+10 -7
View File
@@ -12,8 +12,8 @@ from atlassian.client import basic_auth, Http, jira_json, ToAdf, ToMarkdown
from plan.todo_table import BLOCKED_BY, Item, item_fields, ItemFields, MOVES, SHAPE
from plan_store.markdown_edits import bold_cell, plain, unfit_text
from plan_store.plans import cells, no_item, Plan, Written
from atlassian.jira import entry_of, finishing_transition, ISSUE_KEY, Link, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, unshaped
from project_config.settings import Epic, Finish, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION
from project_config.settings import DEFAULT_ISSUE_TYPE, Epic, Finish, JIRA_FINISH_STATUS, JIRA_FINISH_TRANSITION
from atlassian.jira import entry_of, finishing_transition, ISSUE_KEY, issue_type_refusal, Link, MAX_PAGES, move_refusal, PERHAPS_FILED, PERHAPS_MOVED, project_of, rank_refusal, searched, unshaped
from failure import Failure
from plan.release import parsed, Release, tagged
from plan import ranking
@@ -23,7 +23,6 @@ PROPERTY = "plan-item"
# The key in PROPERTY's value that marks an issue the loop filed, and its value. An edit of an issue without it, which a person filed, writes only PROPERTY and a comment.
FILED_BY = ("Filed by", "loop")
# The issue type of an issue the loop files, which Jira Software's project templates all have; a project without it refuses the issue, saying so.
ISSUE_TYPE = "Task"
# The name of the link type whose inward side reads "is blocked by", as Jira Cloud ships it.
BLOCKS = "Blocks"
SECURITY = "security"
@@ -73,6 +72,8 @@ class JiraPlan:
finish_by: Finish | None = None
# The pages a search may take before the read fails.
max_pages: int = MAX_PAGES
# The issue type `add` files an item as.
finding_type: str = DEFAULT_ISSUE_TYPE
# How add scores an item: by the config's formula and bar, with the goal weights the project's records give.
scoring: ReadsScoring = dataclasses.field(kw_only=True)
@@ -98,7 +99,7 @@ class JiraPlan:
"""Files the item as a child issue, where it scores at the config's bar or above or is exempt, and ranks it as `placing` says.
Jira takes the links and the rank after the issue. One it refuses leaves the issue filed, so the write counts as landed, and a note says what to do by hand."""
filing = filing_of(fields, detail, self.epic)
filing = filing_of(fields, detail, self.epic, self.finding_type)
if isinstance(filing, Failure):
return filing
scoring = self.scoring.read()
@@ -113,6 +114,8 @@ class JiraPlan:
description = self.description_of(detail)
if isinstance(description, Failure):
return description
if refused := issue_type_refusal(self.epic.site, project_of(self.epic.key), self.finding_type, authorization, self.http):
return Failure(refused)
issue_fields = filing.fields | ({"description": description} if description else {})
version = self.fix_version(filing.release, authorization)
if isinstance(version, Failure):
@@ -276,8 +279,8 @@ class Filing:
item: Item
def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failure:
"""The issue to file for an item with these fields under epic, or why a field cannot be filed."""
def filing_of(fields: dict[str, str], detail: str, epic: Epic, issue_type: str) -> Filing | Failure:
"""The issue to file, of the type named issue_type, for an item with these fields under epic, or why a field cannot be filed."""
named = cells(fields)
summary = plain(named.get("Item", "")).strip()
if not summary:
@@ -290,7 +293,7 @@ def filing_of(fields: dict[str, str], detail: str, epic: Epic) -> Filing | Failu
return checked
assert checked.release is not None, "item_fields refuses an empty Release"
project = project_of(epic.key)
issue_fields: dict[str, typing.Any] = {"project": {"key": project}, "parent": {"key": epic.key}, "issuetype": {"name": ISSUE_TYPE}, "summary": summary}
issue_fields: dict[str, typing.Any] = {"project": {"key": project}, "parent": {"key": epic.key}, "issuetype": {"name": issue_type}, "summary": summary}
if checked.exempt == SECURITY:
issue_fields["labels"] = [SECURITY]
value = checked.scores | {MOVES: named.get(MOVES, ""), "Exempt": checked.exempt, FILED_BY[0]: FILED_BY[1]}