Merge remote-tracking branch 'origin/main' into item-287
CI / tests (pull_request) Successful in 2m58s

This commit is contained in:
2026-11-17 00:10:11 +01:00
8 changed files with 61 additions and 31 deletions
+3 -2
View File
@@ -29,8 +29,9 @@ merge merges the pull request in its turn: the chunks of one project on this
turns, one at a time. Run it in the background. In its turn it:
1. fetches origin and merges its default branch into the branch, as sync does;
2. finishes each plan item a --finish names with `todo-item finish`, passing on
--changelog or --no-changelog, and commits what that changed in the plan and the
changelog, so both change only at merge time, on top of every chunk merged before;
--changelog or --no-changelog (a Jira plan takes no --changelog, as todo-item says),
and commits what that changed in the plan and the changelog, so both change only
at merge time, on top of every chunk merged before;
3. pushes, also where step 2 failed after step 1 brought changes in;
4. waits for the pull request's checks, and those origin's default branch requires, to
pass on the head; where no check reports within a minute, it takes the pull request
+11 -3
View File
@@ -63,7 +63,9 @@ mistake. It prints `Finished item <ID> in <plan>.` It doesn't write anything whi
finish <ID> --no-changelog also drops an item no chunk built.
In a Jira epic, finish doesn't remove anything: it moves the item's issue by the transition, and to
the status, that the config's `jira-finish-transition` and `jira-finish-status` name, as
`project-config --help` shows. The --changelog rules hold there too, and docs/decisions.md isn't checked.
`project-config --help` shows. The issues' history is the changelog, so finish there needs
neither --changelog nor --no-changelog, and never reads the changelog. It refuses --changelog and
accepts --no-changelog. docs/decisions.md isn't checked.
It fails, moving no issue, where the config sets neither, where the issue has no such transition
from its present status, or where the transition leads to another status or to one Jira doesn't
count as done. An issue that no chunk built is dropped in Jira, not with finish, which would mark it done.
@@ -116,7 +118,8 @@ def main(argv: list[str], folder: pathlib.Path = pathlib.Path(), stdin: typing.T
case "move":
done = reported(plan.edit(args.id, {"Release": args.release}, None), "not moved", lambda written: f"Moved item {written.id} to release {args.release} in {plan.label}.")
case _:
done = finish(args, plan, store(config, "changelog"))
# A Jira plan keeps no changelog: the issues' history in Jira says what shipped.
done = finish(args, plan, None if config.epic else store(config, "changelog"))
if isinstance(done, Failure):
print(done.reason, file=sys.stderr)
return 1
@@ -217,7 +220,12 @@ def edit(args: argparse.Namespace, plan: PlanStore, text: str) -> str | Failure:
return reported(plan.edit(args.id, fields(args), detail, args.comment), "not edited", lambda written: f"Edited item {written.id} in {plan.label}.")
def finish(args: argparse.Namespace, plan: PlanStore, changelog: RecordStore) -> str | Failure:
def finish(args: argparse.Namespace, plan: PlanStore, changelog: RecordStore | None) -> str | Failure:
"""Finish item args.id in plan. changelog is where its bullet goes, or None where the plan keeps no changelog."""
if changelog is None:
if args.changelog is not None:
return Failure("not finished: the plan is a Jira epic, so the issues' history is the changelog; drop --changelog")
return reported(plan.finish(args.id), "not finished", lambda written: f"Finished item {written.id} in {plan.label}.")
held = changelog.held()
if isinstance(held, Failure):
return Failure(f"not finished: {held.reason}")
+40 -1
View File
@@ -4,10 +4,11 @@ import pathlib
import sys
import tempfile
import unittest
import unittest.mock
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent))
from project_config.test_project_config import configured
from project_config.test_project_config import configured, JIRA_PLAN, JIRA_SCORING
from plan.test_ranking import DECISIONS, README, TODO
from project_config.settings import DEFAULT_FLOOR
from todo_item import edits, main
@@ -266,6 +267,44 @@ class Finish(TodoItem):
self.assertEqual(self.todo.read_text(), before)
class FinishInJira(TodoItem):
"""A plan kept as a Jira epic keeps no changelog: the issues' history in Jira says what shipped."""
def setUp(self):
super().setUp()
self.config.write_text(self.config.read_text().replace('"checkout:todo.md"', f'"{JIRA_PLAN}"') + 'env-file = "~/acme.env"\n' + JIRA_SCORING)
self.plan = MemoryPlan({3: {"Release": "0.1.0", "Item": "**Count the runs.**", "L": "1", "E": "2", "I": "3", "S": "1"}})
patched = unittest.mock.patch.object(main, "plan_store", return_value=self.plan)
patched.start()
self.addCleanup(patched.stop)
def test_finishes_without_either_flag_and_doesnt_touch_the_changelog(self):
self.changelog.write_text(CHANGELOG)
self.assertEqual(self.run_main("finish", "3"), (0, "Finished item 3 in the plan in memory.\n", ""))
self.assertEqual((self.plan.rows, self.changelog.read_text()), ({}, CHANGELOG))
def test_finishes_with_no_changelog_so_chunk_pr_merge_keeps_working(self):
self.changelog.write_text(CHANGELOG)
self.assertEqual(self.run_main("finish", "3", "--no-changelog"), (0, "Finished item 3 in the plan in memory.\n", ""))
self.assertEqual(self.changelog.read_text(), CHANGELOG)
def test_refuses_a_bullet_and_says_the_issues_history_is_the_changelog(self):
self.changelog.write_text(CHANGELOG)
code, out, err = self.run_main("finish", "3", "--changelog", "Runs are fast.")
self.assertEqual((code, out), (1, ""))
self.assertTrue(err.startswith("not finished: "), err)
self.assertIn("the issues' history is the changelog", err)
self.assertEqual((list(self.plan.rows), self.changelog.read_text()), ([3], CHANGELOG))
def test_a_failing_finish_says_not_finished(self):
self.plan.fails = "Jira refused"
self.assertEqual(self.run_main("finish", "3"), (1, "", "not finished: Jira refused\n"))
def test_doesnt_read_the_changelog(self):
self.changelog.write_bytes(b"# Changelog\n\n\xff\n")
self.assertEqual(self.run_main("finish", "3")[::2], (0, ""))
class Show(TodoItem):
def test_prints_the_header_the_row_and_the_detail(self):
row = "| 3 | 0.1.0 | | | **Make it fast, `a \\| b`.** | 2 | 1 | 2 | 3 | 7 | 2.1 by 8, 1 by 6 |"