generated from coulomb/repo-seed
Harden reconciliation conflict handling
This commit is contained in:
@@ -66,6 +66,19 @@ def task_block_linked(path: Path, task_id: uuid.UUID) -> bool:
|
||||
return _task_block_for_task(path, task_id) is not None
|
||||
|
||||
|
||||
def workplan_status(path: Path) -> str | None:
|
||||
status = _frontmatter(path).get("status")
|
||||
return str(status).strip() if status is not None else None
|
||||
|
||||
|
||||
def task_block_status(path: Path, task_id: uuid.UUID) -> str | None:
|
||||
meta = _task_block_for_task(path, task_id)
|
||||
if meta is None:
|
||||
return None
|
||||
status = meta.get("status")
|
||||
return str(status).strip() if status is not None else None
|
||||
|
||||
|
||||
def patch_workplan_status(path: Path, status: str) -> bool:
|
||||
return _patch_frontmatter_field(path, "status", status)
|
||||
|
||||
@@ -140,7 +153,10 @@ def _patch_frontmatter_field(path: Path, key: str, value: str) -> bool:
|
||||
|
||||
|
||||
def _task_block_for_task(path: Path, task_id: uuid.UUID) -> dict[str, Any] | None:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
except OSError:
|
||||
return None
|
||||
for match in _TASK_BLOCK_RE.finditer(text):
|
||||
meta = _parse_task_block(match.group(1))
|
||||
if str(meta.get("state_hub_task_id", "")).strip().strip('"') == str(task_id):
|
||||
|
||||
Reference in New Issue
Block a user