From b58dd6736692bed0202ce403465d8a9752ca61e0 Mon Sep 17 00:00:00 2001 From: SHAREit Date: Fri, 16 Oct 2026 15:16:40 +0800 Subject: [PATCH] fix: restrict data publish staging --- scripts/af_click_gap_pipeline.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/af_click_gap_pipeline.py b/scripts/af_click_gap_pipeline.py index 6f31d08..28b7bba 100755 --- a/scripts/af_click_gap_pipeline.py +++ b/scripts/af_click_gap_pipeline.py @@ -176,11 +176,18 @@ def git_publish(repo: Path, start: str, end: str, no_push: bool) -> str: if not (repo / ".git").exists(): raise RuntimeError("仓库尚未初始化") status = git_run(repo, ["status", "--porcelain", "--untracked-files=all"]).stdout.strip().splitlines() - allowed = re.compile(r"data/(?:index|[0-9]{8})\.json$") - unexpected = [line for line in status if len(line) < 4 or not allowed.fullmatch(line[3:])] + allowed = re.compile(r"data/(?:index\.json|[0-9]{8}\.json)$") + allowed_paths = [] + unexpected = [] + for line in status: + path = line[3:] if len(line) >= 4 else "" + if not allowed.fullmatch(path): + unexpected.append(line) + else: + allowed_paths.append(path) if unexpected: raise RuntimeError("工作区已有未预期改动: " + ", ".join(unexpected)) - add = git_run(repo, ["add", "--", "data"]) + add = git_run(repo, ["add", "--", *allowed_paths]) if add.returncode: raise RuntimeError("git add 失败: " + add.stderr.strip()) staged = git_run(repo, ["diff", "--cached", "--name-only"])