fix: allow generated data outputs

This commit is contained in:
SHAREit
2026-10-16 15:14:47 +08:00
parent e3e7d0cdf4
commit af245d2bab
10 changed files with 46 additions and 6 deletions
+4 -5
View File
@@ -175,13 +175,12 @@ def git_run(repo: Path, args: list[str]) -> subprocess.CompletedProcess[str]:
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"]).stdout.strip().splitlines()
allowed = {"README.md", ".gitignore", "index.html", "scripts/af_click_gap_pipeline.py", "launchd/com.roasbloom.af-click-gap.plist.template"}
allowed.update({f"data/{date.name}" for date in (repo / "data").glob("*.json")})
unexpected = [line for line in status if len(line) < 4 or line[3:] not in allowed]
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:])]
if unexpected:
raise RuntimeError("工作区已有未预期改动: " + ", ".join(unexpected))
add = git_run(repo, ["add", "README.md", ".gitignore", "index.html", "scripts/af_click_gap_pipeline.py", "launchd/com.roasbloom.af-click-gap.plist.template", "data"])
add = git_run(repo, ["add", "--", "data"])
if add.returncode:
raise RuntimeError("git add 失败: " + add.stderr.strip())
staged = git_run(repo, ["diff", "--cached", "--name-only"])