diff --git a/automation/workflow.py b/automation/workflow.py index ace20e6..0a80275 100644 --- a/automation/workflow.py +++ b/automation/workflow.py @@ -77,41 +77,45 @@ def parse_votes(path: Path) -> Mapping[str, str]: return {} for idx, line in enumerate(text.splitlines()): - if VOTE_TOKEN not in line.lower(): - continue + participant_name, remaining_line = _extract_participant(line) + + # Now, search for "VOTE:" in the remaining_line + lower_remaining_line = remaining_line.lower() + marker_idx = lower_remaining_line.rfind(VOTE_TOKEN) + + if marker_idx == -1: + continue # No VOTE_TOKEN found in this part of the line - participant = _extract_participant(line) or f"line-{idx}" - vote_value = _extract_vote_value(line) + # Extract the part after VOTE_TOKEN and pass to _extract_vote_value + vote_string_candidate = remaining_line[marker_idx + len(VOTE_TOKEN):].strip() + + vote_value = _extract_vote_value(vote_string_candidate) + if vote_value: - latest_per_participant[participant] = vote_value + # Determine the participant key + participant_key = participant_name if participant_name else f"line-{idx}" + latest_per_participant[participant_key] = vote_value return latest_per_participant -def _extract_participant(line: str) -> str | None: +def _extract_participant(line: str) -> tuple[str | None, str]: stripped = line.strip() if not stripped: - return None + return None, line if stripped[0] in "-*": parts = stripped[1:].split(":", 1) - if parts: + if len(parts) == 2: candidate = parts[0].strip() if candidate: - return candidate + return candidate, parts[1].strip() + return None, line + + +def _extract_vote_value(vote_string: str) -> str | None: + potential_vote = vote_string.strip().upper() + if potential_vote in ("READY", "CHANGES", "REJECT"): + return potential_vote return None - - -def _extract_vote_value(line: str) -> str | None: - lower = line.lower() - marker_idx = lower.find(VOTE_TOKEN) - if marker_idx == -1: - return None - after = line[marker_idx + len(VOTE_TOKEN):].strip() - if not after: - return None - token = after.split()[0] - return token.upper() - - def print_vote_summary(path: Path, votes: Mapping[str, str]) -> None: rel = path.as_posix() print(f"[workflow] {rel}") diff --git a/src/cascadingdev/setup_project.py b/src/cascadingdev/setup_project.py index eca3ad2..8c2baa8 100644 --- a/src/cascadingdev/setup_project.py +++ b/src/cascadingdev/setup_project.py @@ -378,6 +378,10 @@ def copy_install_assets_to_target(target: Path): # Example: copy starter automation folder if provided in installer if (INSTALL_ROOT / "automation").exists(): shutil.copytree(INSTALL_ROOT / "automation", target / "automation", dirs_exist_ok=True) + # Make workflow.py executable so pre-commit hook can run it + workflow_py = target / "automation" / "workflow.py" + if workflow_py.exists(): + workflow_py.chmod(0o755) def first_commit(target: Path):