Skip to content

Commit 1fdd65f

Browse files
ci(#159): ignore block-scalar payload in workflow contract parser
1 parent 78023b3 commit 1fdd65f

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

.github/scripts/check_agent_branch_triggers.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
ROOT / ".github" / "workflows" / "ci-qutip.yml",
2828
ROOT / ".github" / "workflows" / "quality-contract.yml",
2929
}
30-
PR_HEAD_REF = "${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}"
30+
PR_HEAD_REF = "${{ github.event.pull_request.head.sha }}"
31+
PR_ONLY_IF = "${{ github.event_name == 'pull_request' }}"
3132
TASK_PREFIX_RE = re.compile(r"`([A-Za-z0-9_-]+)/<task>`")
33+
BLOCK_SCALAR_RE = re.compile(r"[:=-]\\s*[|>][+-]?\\s*$")
3234

3335

3436
def _documented_agent_prefixes() -> set[str]:
@@ -39,6 +41,28 @@ def _documented_agent_prefixes() -> set[str]:
3941
return {prefix for prefix in prefixes if "|" not in prefix}
4042

4143

44+
def _structural_lines(path: Path) -> list[tuple[int, int, str]]:
45+
"""Return structural YAML lines, excluding block-scalar payload."""
46+
out: list[tuple[int, int, str]] = []
47+
scalar_indent: int | None = None
48+
for lineno, raw in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
49+
if not raw.strip():
50+
continue
51+
indent = len(raw) - len(raw.lstrip(" "))
52+
if scalar_indent is not None:
53+
if indent > scalar_indent:
54+
continue
55+
scalar_indent = None
56+
code = _yaml_code(raw)
57+
if not code.strip():
58+
continue
59+
indent = len(code) - len(code.lstrip(" "))
60+
stripped = code.strip()
61+
out.append((lineno, indent, stripped))
62+
if BLOCK_SCALAR_RE.search(stripped):
63+
scalar_indent = indent
64+
return out
65+
4266
def _push_branches(path: Path) -> set[str]:
4367
lines = path.read_text(encoding="utf-8").splitlines()
4468
push_index = next(

0 commit comments

Comments
 (0)