Peach: Local-first video metadata scraper and media manager.
feat(tooling): 同步项目看板的需求状态与发布记录
longmeidao607d2c2c0919
diff --git a/.github/project-board.json b/.github/project-board.jsonnew file mode 100644index 000000000..08a4ba565--- /dev/null+++ b/.github/project-board.json@@ -0,0 +1,10 @@+{+ "repository": "peach-mitao/peach",+ "project_id": "PVT_kwDOE_1hCc4BncGL",+ "implementation_commits": {+ "53": ["b2bdb529b536723138144cedc996c8530df2a336"],+ "61": ["03eb94e22387e9ba3fc2401a2b5c73f64f525a44"],+ "62": ["7887699b3ee4059325ace140744904a39bb5bb4a"],+ "65": ["7cf62507ce6148af6e9b06af724b8764cf547cbf"]+ }+}diff --git a/.github/workflows/project-board.yml b/.github/workflows/project-board.ymlnew file mode 100644index 000000000..052d8d073--- /dev/null+++ b/.github/workflows/project-board.yml@@ -0,0 +1,44 @@+name: 项目看板同步++on:+ issues:+ types: [opened, reopened, closed, labeled, unlabeled, edited]+ pull_request_target:+ types: [opened, reopened, closed, edited, ready_for_review, converted_to_draft]+ release:+ types: [published, edited, deleted]+ push:+ branches: [master]+ workflow_dispatch:++permissions:+ contents: read++concurrency:+ group: peach-project-board+ cancel-in-progress: false++jobs:+ sync:+ if: github.repository == 'peach-mitao/peach'+ runs-on: ubuntu-latest+ timeout-minutes: 10+ steps:+ - uses: actions/checkout@v7+ with:+ ref: master+ fetch-depth: 0+ persist-credentials: false+ - uses: actions/setup-python@v7+ with:+ python-version: '3.14'+ - name: 同步 Issue、PR、已发布版本与看板+ env:+ GH_TOKEN: ${{ secrets.PROJECT_BOARD_TOKEN }}+ PYTHONUTF8: '1'+ run: |+ if [ -z "$GH_TOKEN" ]; then+ echo '缺少 PROJECT_BOARD_TOKEN:需要 repo 与 project 权限的项目自动化凭据。' >&2+ exit 1+ fi+ python scripts/project_board.py --apply --event "$GITHUB_EVENT_PATH"diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 2fdcb1a8e..24f1dbadb 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -256,3 +256,18 @@ jobs:cd releasesha256sum ./*.zip ./*-setup.exe > SHA256SUMS.txtgh release create "$GITHUB_REF_NAME" ./*.zip ./*-setup.exe SHA256SUMS.txt --verify-tag --prerelease --title "Peach $VERSION · Windows 测试版" --notes-file RELEASE_NOTES.md++ project-board:+ name: 同步已发布版本到看板+ if: github.ref_type == 'tag'+ needs: release+ runs-on: ubuntu-latest+ timeout-minutes: 5+ permissions:+ actions: write+ steps:+ - name: 请求项目看板同步+ env:+ GH_TOKEN: ${{ github.token }}+ GH_REPO: ${{ github.repository }}+ run: gh workflow run project-board.yml --ref masterdiff --git a/docs/BROWSER_HISTORY.md b/docs/BROWSER_HISTORY.mdindex 81dc9d9f7..d6765cb1c 100644--- a/docs/BROWSER_HISTORY.md+++ b/docs/BROWSER_HISTORY.md@@ -29,6 +29,6 @@ Firefox 自定义资料可以从 `about:profiles` 找到根目录后手动添加浏览器数据库先经 SQLite backup 取得一致快照,再由固定的 `browserexport==0.4.4` 转换访问时间与记录。Chrome 的可选停留时长、Firefox 的可选描述与预览图缺失时仍可读取;一份资料损坏不阻断其他资料。原始 URL 与标题只保存在私有历史库,不进入 ledger。-临时 SQLite 回归覆盖目录发现、手动添加、停止与恢复、增量去重、可选列、错误格式、特殊路径字符及本机单份失败隔离。本机 115 的真实文件已在临时私有库完成读取与重复导入验收,源文件哈希保持一致;记录仅保留计数和通过状态,没有 URL 或标题。其他浏览器的目录支持不表示已对其当前版本完成实机验收。issue [#65](https://github.com/peach-mitao/peach/issues/65) 报告者环境仍待修复版本发布后复测。+临时 SQLite 回归覆盖目录发现、手动添加、停止与恢复、增量去重、可选列、错误格式、特殊路径字符及本机单份失败隔离。本机 115 的真实文件已在临时私有库完成读取与重复导入验收,源文件哈希保持一致;记录仅保留计数和通过状态,没有 URL 或标题。其他浏览器的目录支持不表示已对其当前版本完成实机验收。修复已随 v0.43.0 发布,issue [#65](https://github.com/peach-mitao/peach/issues/65) 等待报告者在其环境复测。桌面与手机页面沿用现有浏览器来源管理,本次没有布局或交互改动。diff --git a/docs/PRODUCT_BACKLOG.md b/docs/PRODUCT_BACKLOG.mdindex c2aa6c2bc..9e04faafe 100644--- a/docs/PRODUCT_BACKLOG.md+++ b/docs/PRODUCT_BACKLOG.md@@ -2,11 +2,11 @@最后核验:2026-10-07。这里只记还没做完的需求和待执行的操作;做完就删,历史去 Git 查。运行数字以 `peach-data/state/job-status.md` 的自动区块为准。-当前开发与版本范围见 [Peach 开发进度](https://github.com/orgs/peach-mitao/projects/6);本文件保留资料复核、运维等待条件与长期待办。+当前开发与版本范围见 [Peach 项目看板](https://github.com/orgs/peach-mitao/projects/6),关联与自动同步方式见[项目看板与交付关联](PROJECT_BOARD.md);本文件保留资料复核、运维等待条件与长期待办。## 功能验收与范围-- [#65 115 历史导入](https://github.com/peach-mitao/peach/issues/65):本机真实 `HistoryEx` 的发现、读取与去重已验收;待修复版本发布后由报告者复测。目录与格式范围见[浏览器历史导入](BROWSER_HISTORY.md)。+- [#65 115 历史导入](https://github.com/peach-mitao/peach/issues/65):本机真实 `HistoryEx` 的发现、读取与去重已验收,修复已随 v0.43.0 发布,等待报告者复测。目录与格式范围见[浏览器历史导入](BROWSER_HISTORY.md)。- #61 的 OneDrive、光鸭与通用挂载来源待真实账号验收;#62 的真实 STRM 上游兼容性待补,合成 HTTP Range 与 HLS 回归在隔离环境验证。- [#63 Emby/Jellyfin 兼容](https://github.com/peach-mitao/peach/issues/63)待明确目标客户端、认证、媒体库查询、播放与进度接口范围。diff --git a/docs/PROJECT_BOARD.md b/docs/PROJECT_BOARD.mdnew file mode 100644index 000000000..7b1091928--- /dev/null+++ b/docs/PROJECT_BOARD.md@@ -0,0 +1,37 @@+# 项目看板与交付关联++[Peach 项目看板](https://github.com/orgs/peach-mitao/projects/6)收录产品需求、缺陷与工程任务。正式事项使用 GitHub Issue 编号;草稿保留讨论范围与优先级,逐项确认后再决定是否转为 Issue。卡片正文的相关事项链接用于说明依赖。个人馆藏修正、账号登录与设备维护留在本机清单,条件尚不满足的研究项保留归档。++## 状态与版本++| 字段 | 含义 |+| --- | --- |+| Status | 待评估、待安排、进行中、待验证、已完成、已取消;PR 另有已关闭未合入,描述真实处理结果 |+| Priority | P0 紧急、P1 优先、P2 常规、P3 低优先级 |+| 计划阶段 | 近期、后续、探索;不构成交付日期承诺 |+| 等待条件 | 阻止下一步的具体条件;没有阻塞时留空 |+| 实现关联 | 已关联的 PR 或经核对的实现提交 |+| 交付进度 | 未关联实现、尚未合入、已合入待发布、已发布 |+| 发布版本、发布说明 | 首次实际包含实现的可下载版本及其链接 |+| Milestone | 计划交付范围;与实际发布版本分别记录 |++PR 合入表示代码已集成。开放的需求进入待验证;完成验收后关闭 Issue 才进入已完成。关闭原因是「不计划」时进入已取消。发布版本不会代替目标环境或报告者验收。++## 自动同步++`.github/workflows/project-board.yml` 响应 Issue 开关和标签变化、PR 建立和合入、主线推送、Release 发布与变动。使用主线代码,不检出或执行外部 PR 的代码。所有同步串行执行,每次读取当前事实,重复执行不会重复建卡或推进状态。++- 新建 Issue、PR 自动加入看板,每轮补查开放事项。重新打开的事项按实际实现恢复为待安排或待验证,开放 PR 为进行中。+- PR 的 GitHub 关联和独立 `Refs #编号` 行建立实现关联;只处理本仓库引用。正文中普通提及某个编号不会被当成交付。+- 已合入 PR 对应的开放需求进入待验证;`status:needs-info` 和 `status:needs-verification` 分别保留等待信息和验收的含义。+- 从有下载制品的已发布 Release 中检查标签提交祖先关系,填写首次包含实现的版本。只有标签、失败构建和发布草稿均不算已发布。+- 通过 Actions 的仓库令牌创建 Release 不会触发另一条 Release 工作流;发布工作流在上架后显式调用同一同步入口。+- 不关闭 Issue,不合入 PR,不修改优先级、排期或归档状态。已归档事项不自动恢复。++历史直接集成而没有 PR 的实现,在 `.github/project-board.json` 登记完整提交 SHA;同步同样验证其是否属于主线和发布标签,不凭文字宣称完成。++## 凭据与验证++组织 Project 不接受仓库默认的 `GITHUB_TOKEN`。`PROJECT_BOARD_TOKEN` 必须具备仓库读取与 Project 写权限,通过 GitHub Actions Secret 注入;不得写入代码、日志或事件正文。GitHub App 可按[官方方法](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions)替代长期令牌。++本地运行 `scripts/project_board.py` 默认只预览差异,显式传入 `--apply` 才写入。回归覆盖开关、合入、待验收、发布祖先关系和跨仓库引用;线上验收使用手动触发和实际看板读回。diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 7367ec21e..2bc013a30 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -1,5 +1,9 @@# 复用清单+## GitHub 项目看板++看板同步复用 GitHub CLI 的已登录认证、GraphQL Projects API 和 Git 的提交祖先校验;不新增 Python 依赖。官方 [Projects Actions 自动化](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions)支持独立项目凭据,仓库默认令牌不能写组织 Project。项目原生状态工作流没有发布标签与制品归属判定;通用自动加卡 Action 也不覆盖验收和发布的分别记录,因此由 `scripts/project_board.py` 保留 Peach 的状态规则,传输与认证交给系统已安装的 `gh`。运行依赖是官方维护、MIT 许可的 GitHub CLI 和 GPL-2.0 Git,使用 GitHub 托管 runner 内置版本;本机只读 GraphQL 与标签祖先验证后再应用。无生产服务、ledger 或媒体写入。+## JAV 用户脚本添加用户脚本模板 `web/integrations/peach-jav.user.js`(0.2.0)使用 [Tampermonkey 官方 GM API](https://www.tampermonkey.net/documentation.php) 的本机存储、菜单与 `GM_xmlhttpRequest`;SPA 通知依据 `window.onurlchange` 契约。`jav-sites.json` 集中登记站点、域名、详情规则、明确字段和作品参数,安装端点生成 `@match` 与脚本运行规则,设置页读取同一份清单。脚本独立编写,不复制第三方源码、不新增依赖。宿主扩展由用户安装,兼容性以实际浏览器及脚本管理器授权为准;本轮通过模拟 GM API 的真实 Chromium 页面验证,真实扩展安装及源站页面验收未取得。diff --git a/scripts/project_board.py b/scripts/project_board.pynew file mode 100644index 000000000..2c31fecb0--- /dev/null+++ b/scripts/project_board.py@@ -0,0 +1,254 @@+"""按 GitHub 事实同步项目状态、关联实现与已发布版本。默认只预览。"""+from __future__ import annotations++import argparse+import json+import os+from pathlib import Path+import re+import subprocess++ROOT = Path(__file__).resolve().parents[1]+CONFIG = ROOT / ".github/project-board.json"+++def gh(*args, payload=None):+ command = ["gh", *args]+ if payload is not None:+ command += ["--input", "-"]+ result = subprocess.run(command, input=None if payload is None else json.dumps(payload),+ cwd=ROOT, capture_output=True, text=True, encoding="utf-8", timeout=120)+ if result.returncode:+ raise RuntimeError(f"GitHub CLI 调用失败:{result.stderr.strip()} {result.stdout[:2000]}")+ return json.loads(result.stdout) if result.stdout.strip() else None+++def graphql(query, **variables):+ result = gh("api", "graphql", payload={"query": query, "variables": variables})+ if result.get("errors"):+ raise RuntimeError(json.dumps(result["errors"], ensure_ascii=False))+ return result["data"]+++def connection(query, path, **variables):+ """逐页读取,分页游标必须前进。"""+ nodes, cursor = [], None+ while True:+ data = graphql(query, cursor=cursor, **variables)+ for key in path:+ data = data[key]+ nodes.extend(data["nodes"])+ page = data["pageInfo"]+ if not page["hasNextPage"]:+ return nodes+ if not page["endCursor"] or page["endCursor"] == cursor:+ raise RuntimeError("GitHub 分页游标没有前进")+ cursor = page["endCursor"]+++def ancestor(commit, ref):+ if not re.fullmatch(r"[0-9a-f]{40}", commit):+ return False+ result = subprocess.run(["git", "merge-base", "--is-ancestor", commit, ref],+ cwd=ROOT, capture_output=True, timeout=30)+ if result.returncode not in (0, 1, 128):+ raise RuntimeError("提交归属验证失败")+ return result.returncode == 0+++def references(body, repository):+ """只接受独立的关联行,不把正文中随手提到的编号当成交付。"""+ found = set()+ for line in body.splitlines():+ if not re.match(r"^\s*(?:refs?|closes?|fix(?:es)?|resolves?)\s*[::]?\s+", line, re.I):+ continue+ for repo, number in re.findall(r"(?:(\w[\w.-]*/[\w.-]+))?#(\d+)", line):+ if not repo or repo.casefold() == repository.casefold():+ found.add(int(number))+ return found+++def values(item):+ return {value["field"]["name"]: value.get("name", value.get("text", ""))+ for value in item.get("fieldValues", {}).get("nodes", []) if value}+++def decision(content, current, linked, published):+ """状态服从关闭原因与验收;交付进度单独呈现。"""+ is_pr = content["__typename"] == "PullRequest"+ merged = bool(content.get("merged")) if is_pr else any(pr.get("merged") for pr in linked)+ labels = {label["name"] for label in content.get("labels", {}).get("nodes", [])}+ status = current.get("Status", "待评估")+ if is_pr:+ status = "已完成" if merged else ("已关闭未合入" if content["state"] == "CLOSED" else "进行中")+ elif content["state"] == "CLOSED":+ status = "已取消" if content.get("stateReason") == "NOT_PLANNED" else "已完成"+ elif "status:needs-verification" in labels:+ status = "待验证"+ elif "status:needs-info" in labels:+ status = "待评估"+ elif merged:+ status = "待验证"+ elif linked:+ status = "进行中"+ elif status in {"已完成", "已取消"}:+ status = "待安排"+ delivery = "已发布" if published else ("已合入待发布" if merged else (+ "尚未合入" if linked or is_pr else "未关联实现"))+ result = {"Status": status, "交付进度": delivery, "发布版本": "", "发布说明": "", "实现关联": ""}+ if published:+ result.update({"发布版本": published["tag_name"], "发布说明": published["html_url"]})+ return result+++CONTENT = '''__typename ... on DraftIssue{id title} ... on Issue{id number title url state stateReason+labels(first:100){nodes{name}}}+... on PullRequest{id number title url state merged mergeCommit{oid} body+closingIssuesReferences(first:100){nodes{id number}}}'''+PR_CONTENT = '''__typename id number title url state merged mergeCommit{oid} body+closingIssuesReferences(first:100){nodes{id number}}'''+++def read_project(project):+ fields = graphql('''query($id:ID!){node(id:$id){... on ProjectV2{+fields(first:100){nodes{... on ProjectV2Field{id name dataType}+... on ProjectV2SingleSelectField{id name options{id name}}}}}}}''', id=project)["node"]["fields"]["nodes"]+ fields = {field["name"]: field for field in fields if "name" in field}+ for required in ("Status", "交付进度", "发布版本", "发布说明", "实现关联"):+ if required not in fields:+ raise ValueError(f"看板缺少字段:{required}")+ items = connection('''query($id:ID!,$cursor:String){node(id:$id){... on ProjectV2{+items(first:100,after:$cursor){nodes{id isArchived content{''' + CONTENT + '''}+fieldValues(first:100){nodes{... on ProjectV2ItemFieldSingleSelectValue{name field{... on ProjectV2SingleSelectField{name}}}+... on ProjectV2ItemFieldTextValue{text field{... on ProjectV2Field{name}}}}}}+pageInfo{hasNextPage endCursor}}}}}''', ("node", "items"), id=project)+ return fields, items+++def pull_requests(repository):+ owner, name = repository.split("/")+ return connection('''query($owner:String!,$name:String!,$cursor:String){repository(owner:$owner,name:$name){+pullRequests(first:100,after:$cursor,orderBy:{field:CREATED_AT,direction:DESC}){nodes{''' + PR_CONTENT + '''}+pageInfo{hasNextPage endCursor}}}}''', ("repository", "pullRequests"), owner=owner, name=name)+++def issue_links(prs, repository):+ linked = {}+ for pr in prs:+ if pr["state"] == "CLOSED" and not pr.get("merged"):+ continue+ numbers = {issue["number"] for issue in pr["closingIssuesReferences"]["nodes"]}+ numbers |= references(pr["body"], repository)+ for number in numbers:+ linked.setdefault(number, []).append(pr)+ return linked+++def include_incoming(config, candidates, prs, event, apply):+ repository, project = config["repository"], config["project_id"]+ owner, name = repository.split("/")+ incoming = connection('''query($owner:String!,$name:String!,$cursor:String){repository(owner:$owner,name:$name){+issues(first:100,after:$cursor,states:OPEN){nodes{__typename id number title url state stateReason+labels(first:100){nodes{name}}}pageInfo{hasNextPage endCursor}}}}''',+ ("repository", "issues"), owner=owner, name=name)+ tracked = {item["content"].get("number") for item in candidates.values()+ if not item["isArchived"] and item["content"]["__typename"] == "Issue"}+ incoming += [pr for pr in prs if pr["state"] == "OPEN" or any(+ issue["number"] in tracked for issue in pr["closingIssuesReferences"]["nodes"])]+ subject = (event or {}).get("issue") or (event or {}).get("pull_request")+ if subject and (event or {}).get("repository", {}).get("full_name") == repository:+ node = graphql('''query($id:ID!){node(id:$id){''' + CONTENT + '''}}''', id=subject["node_id"])["node"]+ incoming.append(node)+ for node in incoming:+ if node["id"] not in candidates:+ item = {"id": None, "content": node, "fieldValues": {"nodes": []}, "isArchived": False}+ if apply:+ item["id"] = graphql('''mutation($project:ID!,$content:ID!){addProjectV2ItemById(+input:{projectId:$project,contentId:$content}){item{id}}}''', project=project, content=node["id"])["addProjectV2ItemById"]["item"]["id"]+ candidates[node["id"]] = item+++def published_releases(repository):+ pages = gh("api", f"repos/{repository}/releases?per_page=100", "--paginate", "--slurp")+ return sorted([release for page in pages for release in page+ if not release["draft"] and release.get("published_at") and release.get("assets")],+ key=lambda release: release["published_at"])+++def delivery_fields(config, content, current, linked, releases):+ repository = config["repository"]+ is_pr = content["__typename"] == "PullRequest"+ associated = [content] if is_pr else linked.get(content["number"], [])+ commits = [pr["mergeCommit"]["oid"] for pr in associated if pr.get("merged") and pr.get("mergeCommit")]+ commits += config.get("implementation_commits", {}).get(str(content["number"]), []) if not is_pr else []+ integrated = [commit for commit in commits if ancestor(commit, "origin/master")]+ if integrated and not is_pr and not any(pr.get("merged") for pr in associated):+ associated = [*associated, {"merged": True}]+ published = next((release for release in releases if any(+ ancestor(commit, f'refs/tags/{release["tag_name"]}') for commit in integrated)), None)+ desired = decision(content, current, associated, published)+ urls = [pr["url"] for pr in associated if pr.get("url")]+ if urls:+ desired["实现关联"] = "\n".join(urls)+ elif integrated:+ desired["实现关联"] = "\n".join(f"https://github.com/{repository}/commit/{commit}" for commit in integrated)+ return desired+++def apply_fields(project, item, fields, desired, apply):+ current, content = values(item), item["content"]+ changes = []+ for field_name, value in desired.items():+ if current.get(field_name, "") == value:+ continue+ field = fields[field_name]+ update = {"singleSelectOptionId": next(option["id"] for option in field["options"] if option["name"] == value)} if "options" in field else {"text": value}+ changes.append({"number": content["number"], "title": content["title"], "field": field_name, "value": value})+ if apply:+ if not value:+ graphql('''mutation($project:ID!,$item:ID!,$field:ID!){clearProjectV2ItemFieldValue(+input:{projectId:$project,itemId:$item,fieldId:$field}){projectV2Item{id}}}''',+ project=project, item=item["id"], field=field["id"])+ continue+ graphql('''mutation($project:ID!,$item:ID!,$field:ID!,$value:ProjectV2FieldValue!){+updateProjectV2ItemFieldValue(input:{projectId:$project,itemId:$item,fieldId:$field,value:$value}){projectV2Item{id}}}''',+ project=project, item=item["id"], field=field["id"], value=update)+ return changes+++def reconcile(config, *, apply=False, event=None):+ project, repository = config["project_id"], config["repository"]+ fields, items = read_project(project)+ prs = pull_requests(repository)+ linked = issue_links(prs, repository)+ candidates = {item["content"]["id"]: item for item in items if item.get("content")}+ include_incoming(config, candidates, prs, event, apply)+ releases = published_releases(repository)+ changes = []+ for item in candidates.values():+ content = item["content"]+ if item["isArchived"] or content["__typename"] not in {"Issue", "PullRequest"}:+ continue+ if not content["url"].startswith(f"https://github.com/{repository}/"):+ continue+ desired = delivery_fields(config, content, values(item), linked, releases)+ changes.extend(apply_fields(project, item, fields, desired, apply))+ return changes+++def main():+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--apply", action="store_true")+ parser.add_argument("--event", type=Path)+ args = parser.parse_args()+ event = json.loads(args.event.read_text(encoding="utf-8")) if args.event else None+ config = json.loads(CONFIG.read_text(encoding="utf-8"))+ if os.environ.get("GITHUB_REPOSITORY", config["repository"]) != config["repository"]:+ raise ValueError("仓库不匹配,拒绝同步项目")+ changes = reconcile(config, apply=args.apply, event=event)+ print(json.dumps({"apply": args.apply, "changes": changes}, ensure_ascii=False, indent=2))+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/tests/test_scripts.py b/tests/test_scripts.pyindex 2a1d03ef6..c73bc2b7d 100644--- a/tests/test_scripts.py+++ b/tests/test_scripts.py@@ -53,6 +53,91 @@ def load_script(name: str):return module+class ProjectBoardTests(unittest.TestCase):+ @classmethod+ def setUpClass(cls):+ cls.script = load_script("project_board")++ def issue(self, **changes):+ return {"__typename": "Issue", "state": "OPEN", "labels": {"nodes": []}, **changes}++ def test_merge_and_publication_keep_open_issue_waiting_for_acceptance(self):+ release = {"tag_name": "v1.2.0", "html_url": "https://example.test/release"}+ result = self.script.decision(self.issue(), {"Status": "进行中"}, [{"merged": True}], release)+ self.assertEqual(result["Status"], "待验证")+ self.assertEqual(result["交付进度"], "已发布")+ self.assertEqual(result["发布版本"], "v1.2.0")++ def test_closed_not_planned_is_cancelled_and_reopened_returns_to_queue(self):+ result = self.script.decision(self.issue(state="CLOSED", stateReason="NOT_PLANNED"), {}, [], None)+ self.assertEqual(result["Status"], "已取消")+ result = self.script.decision(self.issue(), {"Status": "已取消"}, [], None)+ self.assertEqual(result["Status"], "待安排")++ def test_manual_priority_and_queue_are_not_replaced_by_unrelated_activity(self):+ result = self.script.decision(self.issue(), {"Status": "待安排", "Priority": "P1"}, [], None)+ self.assertEqual(result["Status"], "待安排")+ self.assertNotIn("Priority", result)+ waiting = self.issue(labels={"nodes": [{"name": "status:needs-info"}]})+ self.assertEqual(self.script.decision(waiting, {}, [{"merged": True}], None)["Status"], "待评估")++ def test_reference_lines_exclude_other_repositories_and_casual_mentions(self):+ body = "参考 #64 的讨论\nRefs #65, peach-mitao/peach#66, other/repo#67\nCloses #68"+ self.assertEqual(self.script.references(body, "peach-mitao/peach"), {65, 66, 68})++ def test_pr_closure_is_distinct_from_merge(self):+ pr = {"__typename": "PullRequest", "state": "CLOSED", "merged": False}+ self.assertEqual(self.script.decision(pr, {}, [], None)["Status"], "已关闭未合入")+ pr["merged"] = True+ self.assertEqual(self.script.decision(pr, {}, [], None)["交付进度"], "已合入待发布")++ def test_reconcile_uses_published_assets_and_keeps_archived_items_untouched(self):+ commit = "a" * 40+ fields = [{"id": name, "name": name} for name in ("发布版本", "发布说明", "实现关联")]+ fields += [{"id": "status", "name": "Status", "options": [{"id": "verify", "name": "待验证"}]},+ {"id": "delivery", "name": "交付进度", "options": [{"id": "published", "name": "已发布"}]}]+ issue = self.issue(id="issue", number=65, title="历史导入", url="https://github.com/peach-mitao/peach/issues/65")+ item = {"id": "item", "content": issue, "isArchived": False, "fieldValues": {"nodes": []}}+ archived = {**item, "id": "archive", "isArchived": True, "content": {**issue, "id": "old", "number": 90}}+ draft = {"id": "draft", "isArchived": False, "content": {"__typename": "DraftIssue", "id": "draft-content"}}+ releases = [[{"tag_name": tag, "html_url": f"https://example.test/{tag}", "published_at": date,+ "draft": is_draft, "assets": assets} for tag, date, is_draft, assets in [+ ("v0.42.0", "2026-10-16", False, []),+ ("v0.43.0", "2026-10-17", False, [{"name": "app.zip"}]),+ ("v0.44.0", "2026-10-18", True, [{"name": "app.zip"}]),+ ("v0.45.0", "2026-10-19", False, [{"name": "app.zip"}])]]]+ with mock.patch.object(self.script, "graphql", return_value={"node": {"fields": {"nodes": fields}}}) as api, \+ mock.patch.object(self.script, "connection", side_effect=[[item, archived, draft], [], []]), \+ mock.patch.object(self.script, "gh", return_value=releases), \+ mock.patch.object(self.script, "ancestor", return_value=True):+ changes = self.script.reconcile({"project_id": "project", "repository": "peach-mitao/peach",+ "implementation_commits": {"65": [commit]}}, apply=False)+ self.assertEqual(api.call_count, 1)+ self.assertEqual({change["number"] for change in changes}, {65})+ actual = {change["field"]: change["value"] for change in changes}+ self.assertEqual(actual["发布版本"], "v0.43.0")+ self.assertEqual(actual["Status"], "待验证")+ self.assertTrue(actual["实现关联"].endswith(commit))++ def test_ancestor_uses_actual_commit_graph_and_rejects_unmerged_commit(self):+ with tempfile.TemporaryDirectory() as temporary:+ root = Path(temporary).resolve()+ def git(*args):+ return subprocess.run(["git", *args], cwd=root, check=True, capture_output=True,+ text=True, encoding="utf-8").stdout.strip()+ git("init", "-b", "master")+ git("-c", "user.name=Test", "-c", "[email protected]", "commit", "--allow-empty", "-m", "base")+ base = git("rev-parse", "HEAD")+ git("tag", "v1.0")+ git("checkout", "-b", "feature")+ git("-c", "user.name=Test", "-c", "[email protected]", "commit", "--allow-empty", "-m", "feature")+ feature = git("rev-parse", "HEAD")+ with mock.patch.object(self.script, "ROOT", root):+ self.assertTrue(self.script.ancestor(base, "refs/tags/v1.0"))+ self.assertFalse(self.script.ancestor(feature, "refs/tags/v1.0"))+ self.assertFalse(self.script.ancestor("not-a-commit", "refs/tags/v1.0"))++class UpdateTaskSmokeTests(unittest.TestCase):def test_dry_run_does_not_open_artifacts_or_create_installation_data(self):with mock.patch.dict(sys.modules, {'smoke_desktop': load_script('smoke_desktop')}):