Answer stability round 1: 0 🔴, 2 🟡 (0 misread); keep the comment in the fake plan, and name move among the writes Jira may have taken

This commit is contained in:
2026-11-16 02:15:39 +01:00
parent eb5a63edd2
commit 121aba05ea
3 changed files with 19 additions and 12 deletions
+6 -1
View File
@@ -12,6 +12,8 @@ class MemoryPlan:
"""A plan held in memory, as a tracker holds one: in the order filed, unranked, with no bar. Where fails is set, every read and write fails with it as the reason.""" """A plan held in memory, as a tracker holds one: in the order filed, unranked, with no bar. Where fails is set, every read and write fails with it as the reason."""
rows: dict[int, dict[str, str]] = dataclasses.field(default_factory=dict) rows: dict[int, dict[str, str]] = dataclasses.field(default_factory=dict)
details: dict[int, str] = dataclasses.field(default_factory=dict) details: dict[int, str] = dataclasses.field(default_factory=dict)
# Each comment an edit gave, under its item's ID, as a tracker posts them on the item's issue.
comments: dict[int, list[str]] = dataclasses.field(default_factory=dict)
next_id: int = 1 next_id: int = 1
label: str = "the plan in memory" label: str = "the plan in memory"
tracked: str | None = None tracked: str | None = None
@@ -29,7 +31,10 @@ class MemoryPlan:
def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure: def edit(self, id_: int, fields: dict[str, str], detail: str | None, comment: str | None = None) -> Written | Failure:
if id_ not in self.rows: if id_ not in self.rows:
return Failure(f"{self.label} holds no item {id_}") return Failure(f"{self.label} holds no item {id_}")
return self.put(id_, self.rows[id_] | cells(fields), self.details.get(id_, "") if detail is None else detail) written = self.put(id_, self.rows[id_] | cells(fields), self.details.get(id_, "") if detail is None else detail)
if comment is not None and isinstance(written, Written):
self.comments.setdefault(id_, []).append(comment)
return written
def finish(self, id_: int) -> Written | Failure: def finish(self, id_: int) -> Written | Failure:
if self.fails or id_ not in self.rows: if self.fails or id_ not in self.rows:
+7 -5
View File
@@ -39,11 +39,13 @@ empties the cell. --detail replaces the detail with the text on stdin, and --cle
Text on stdin without --detail, and --detail without text on stdin, are refused, so no detail is Text on stdin without --detail, and --detail without text on stdin, are refused, so no detail is
dropped or wiped by mistake. It prints `Edited item <ID> in <plan>.` It doesn't write anything where dropped or wiped by mistake. It prints `Edited item <ID> in <plan>.` It doesn't write anything where
ranking fails or scores the item under the bar. ranking fails or scores the item under the bar.
In a Jira epic, edit changes an issue the loop filed: its summary, description, scores and Fix In a Jira epic, edit changes an issue the loop filed: its summary, description and scores, and
Version, and the label `security` with --exempt. It doesn't change a link, so --blocked-by fails. the label `security` with --exempt. It doesn't change a link, so --blocked-by fails.
Of an issue a person filed it sets only the scores, --moves and --exempt, and only with --comment. Of an issue a person filed it sets only the scores, --moves and --exempt, and only with --comment.
--comment is posted as a comment on the Jira issue, for the client's team: say why the edit is The four scores are set together where the issue holds none yet.
made, in the project's language. A todo.md keeps no comment, so there the flag doesn't do anything. --comment is posted as a comment on the Jira issue, for the client's team, in the project's
language. Jira doesn't show the team the scores, so say that the issue is scored, and why.
A todo.md keeps no comment, so there the flag doesn't do anything.
Where Jira takes the edit and then refuses the comment, edit still prints `Edited item <ID> …`, Where Jira takes the edit and then refuses the comment, edit still prints `Edited item <ID> …`,
and says on stderr to post the comment in Jira. and says on stderr to post the comment in Jira.
@@ -65,7 +67,7 @@ count as done. An issue that no chunk built is dropped in Jira, not with finish,
Exit 2 on bad arguments, and 1, saying why, on any other failure. A message opening `not filed:`, Exit 2 on bad arguments, and 1, saying why, on any other failure. A message opening `not filed:`,
`not edited:`, `not moved:` or `not finished:` means it didn't write anything. The one exception is an add, `not edited:`, `not moved:` or `not finished:` means it didn't write anything. The one exception is an add,
an edit or a finish in a Jira epic that Jira didn't answer or answered brokenly: the message then an edit, a move or a finish in a Jira epic that Jira didn't answer or answered brokenly: the message then
says the issue may exist, may have changed or may have moved. says the issue may exist, may have changed or may have moved.
""" """
import argparse import argparse
+6 -6
View File
@@ -4,7 +4,6 @@ import pathlib
import sys import sys
import tempfile import tempfile
import unittest import unittest
import unittest.mock
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent))
@@ -14,8 +13,9 @@ from project_config.settings import DEFAULT_FLOOR
from todo_item import edits, main from todo_item import edits, main
from failure import Failure from failure import Failure
from project_config.main import located from project_config.main import located
from plan_store.fakes import MemoryPlan
from release_plan import plan_file, ranking from release_plan import plan_file, ranking
from plan_store.stores import plan_of, Written from plan_store.stores import plan_of
from todo_item.table import table from todo_item.table import table
ADD = ["add", "--release", "0.1.0", "--l", "1", "--e", "1", "--i", "1", "--s", "1", "--moves", "1 by 9", "Count the `a | b` runs."] ADD = ["add", "--release", "0.1.0", "--l", "1", "--e", "1", "--i", "1", "--s", "1", "--moves", "1 by 9", "Count the `a | b` runs."]
@@ -419,11 +419,11 @@ class Edit(TodoItem):
self.assertEqual(self.run_main("edit", "3", "--comment", "Why.")[::2], (1, "not edited: no flag names a change; todo-item --help lists them\n")) self.assertEqual(self.run_main("edit", "3", "--comment", "Why.")[::2], (1, "not edited: no flag names a change; todo-item --help lists them\n"))
def test_an_edit_hands_the_comment_to_the_plan(self): def test_an_edit_hands_the_comment_to_the_plan(self):
for argv, comment in ((["--comment", "A small change."], "A small change."), ([], None)): for argv, comments in ((["--comment", "A small change."], {3: ["A small change."]}), ([], {})):
with self.subTest(argv=argv): with self.subTest(argv=argv):
plan = unittest.mock.Mock(label="the plan", edit=unittest.mock.Mock(return_value=Written(3))) plan = MemoryPlan({3: {"Release": "0.1.0", "Item": "**Count the runs.**", "L": "1", "E": "2", "I": "3", "S": "1"}})
self.assertEqual(main.edit(main.parser().parse_args(["edit", "3", "--l", "3", *argv]), plan, ""), "Edited item 3 in the plan.") self.assertEqual(main.edit(main.parser().parse_args(["edit", "3", "--l", "3", *argv]), plan, ""), "Edited item 3 in the plan in memory.")
plan.edit.assert_called_once_with(3, {"L": "3"}, None, comment) self.assertEqual((plan.rows[3]["L"], plan.comments), ("3", comments))
def test_a_plan_in_a_file_takes_an_edit_with_a_comment_and_keeps_no_comment(self): def test_a_plan_in_a_file_takes_an_edit_with_a_comment_and_keeps_no_comment(self):
self.assertEqual(self.run_main("edit", "3", "--l", "3", "--comment", "A small change.")[:2], (0, f"Edited item 3 in {self.todo}.\n")) self.assertEqual(self.run_main("edit", "3", "--l", "3", "--comment", "A small change.")[:2], (0, f"Edited item 3 in {self.todo}.\n"))