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
+1 -1
View File
@@ -33,7 +33,7 @@ python3 scripts/af_click_gap_pipeline.py --no-push # 写 JSON 和 commit,
python3 scripts/af_click_gap_pipeline.py --start-date 2026-10-10 --end-date 2026-10-16 --no-push
```
`--dry-run` 只读取数据库并在仓库外临时目录生成、校验 JSON,不写 `data` 或 Git。正式运行先原子替换数据文件,再执行 Git;数据库查询或校验失败不会发布文件。push 失败会保留本地 commit,不会 force push。工作区存在本任务之外的未提交改动时,脚本拒绝继续。
`--dry-run` 只读取数据库并在仓库外临时目录生成、校验 JSON,不写 `data` 或 Git。正式运行先原子替换 `data/` 输出目录中的数据文件,再执行 Git;数据库查询或校验失败不会发布文件。Git 安全检查只允许本次生成的 `data/*.json`(含 `data/index.json`),工作区存在其它未提交改动时拒绝继续。push 失败会保留本地 commit,不会 force push。
## 看板
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+34
View File
@@ -0,0 +1,34 @@
{
"schema_version": 1,
"generated_at": "2026-10-16T15:13:23+08:00",
"files": [
{
"date": "20261016",
"path": "data/20261016.json"
},
{
"date": "20261015",
"path": "data/20261015.json"
},
{
"date": "20261014",
"path": "data/20261014.json"
},
{
"date": "20261013",
"path": "data/20261013.json"
},
{
"date": "20261012",
"path": "data/20261012.json"
},
{
"date": "20261011",
"path": "data/20261011.json"
},
{
"date": "20261010",
"path": "data/20261010.json"
}
]
}
+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"])