GRM-58: refactor: require tea CLI everywhere, fail on missing Vikunja task

This commit is contained in:
2026-06-22 11:04:51 +00:00
parent 5e270f21d1
commit dcb2ed0fd9
11 changed files with 104 additions and 162 deletions
+14 -4
View File
@@ -109,7 +109,8 @@ def validate_pr_title(pr_title: str, task_id: str) -> None:
def get_vikunja_task_title(task_id: str) -> str:
"""Fetch the Vikunja task title for the given GRM-N identifier.
Returns empty string if VIKUNJA_TOKEN is not set (skip validation).
Returns empty string if VIKUNJA_TOKEN is not set (local dev without token).
Raises ClickException if the token is set but the task is not found.
"""
token = os.environ.get("VIKUNJA_TOKEN", "")
if not token:
@@ -126,17 +127,26 @@ def get_vikunja_task_title(task_id: str) -> str:
if len(tasks) < DEFAULT_PER_PAGE:
break
page += 1
return ""
raise click.ClickException(
_(
"Could not find Vikunja task {task_id} in project {project_id}. "
"Every PR must have a corresponding Vikunja task.",
task_id=task_id,
project_id=VIKUNJA_PROJECT_ID,
)
)
def validate_pr_title_matches_vikunja(pr_title: str, task_id: str) -> None:
"""Validate that PR title matches the Vikunja task title.
Skips validation if VIKUNJA_TOKEN is not set.
Skips validation if VIKUNJA_TOKEN is not set (local dev).
Raises ClickException if the task is not found or the title doesn't match.
"""
vikunja_title = get_vikunja_task_title(task_id)
if not vikunja_title:
click.echo(_("Warning: could not fetch Vikunja task title, skipping title match validation."))
# VIKUNJA_TOKEN not set — skip validation (local dev)
click.echo(_("Warning: VIKUNJA_TOKEN not set, skipping title match validation."))
return
expected = f"{task_id}: {vikunja_title}"
if pr_title != expected: