From bc027a5423ea857acaf148d93927e1d754191708 Mon Sep 17 00:00:00 2001 From: robbond Date: Mon, 1 Jun 2026 19:25:59 +0100 Subject: [PATCH] fix: parse task headings with dash variants --- RUN_LOG.md | 1 + src/rdb_discovery/tasks.py | 2 +- tests/test_tasks.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/RUN_LOG.md b/RUN_LOG.md index bc2db45..d522309 100644 --- a/RUN_LOG.md +++ b/RUN_LOG.md @@ -2,3 +2,4 @@ Run Log 2026-06-01 Bootstrap project structure created. +Fixed TASKS.md parser to match em/en dashes in task headings. diff --git a/src/rdb_discovery/tasks.py b/src/rdb_discovery/tasks.py index 02faa78..ac615fb 100644 --- a/src/rdb_discovery/tasks.py +++ b/src/rdb_discovery/tasks.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from pathlib import Path import re -TASK_HEADING_RE = re.compile(r"^##\s+(TASK-\d+)\s+-\s+(.+)$", re.MULTILINE) +TASK_HEADING_RE = re.compile(r"^##\s+(TASK-\d+)\s+[-–—]\s+(.+)$", re.MULTILINE) STATUS_RE = re.compile(r"^Status:\s*(.+)$", re.MULTILINE) diff --git a/tests/test_tasks.py b/tests/test_tasks.py index b0ba5bd..3f604ee 100644 --- a/tests/test_tasks.py +++ b/tests/test_tasks.py @@ -18,6 +18,36 @@ def test_get_next_task(tmp_path: Path) -> None: assert task.title == "Second" +def test_get_next_task_with_em_dash(tmp_path: Path) -> None: + (tmp_path / "TASKS.md").write_text( + "# TASKS.md\n\n" + "## TASK-001 — First\nStatus: Done\n\n" + "## TASK-002 — Second\nStatus: Todo\n\n", + encoding="utf-8", + ) + + task = get_next_task(tmp_path) + + assert task is not None + assert task.task_id == "TASK-002" + assert task.title == "Second" + + +def test_get_next_task_with_en_dash(tmp_path: Path) -> None: + (tmp_path / "TASKS.md").write_text( + "# TASKS.md\n\n" + "## TASK-001 – First\nStatus: Done\n\n" + "## TASK-002 – Second\nStatus: Todo\n\n", + encoding="utf-8", + ) + + task = get_next_task(tmp_path) + + assert task is not None + assert task.task_id == "TASK-002" + assert task.title == "Second" + + def test_update_task_status(tmp_path: Path) -> None: tasks = tmp_path / "TASKS.md" tasks.write_text(