Peach: Local-first video metadata scraper and media manager.
fix(project): 分仓管理反馈与规划并同步同一看板
longmeidao4aa0db86709a
diff --git a/.github/project-board.json b/.github/project-board.jsonindex eb26d6077..7ad71116e 100644--- a/.github/project-board.json+++ b/.github/project-board.json@@ -2,12 +2,39 @@"repository": "peach-mitao/peach","project_id": "PVT_kwDOE_1hCc4BnjsH","issues_only": true,- "maintainers": ["longmeidao"],+ "issue_repositories": ["peach-mitao/peach", "peach-mitao/peach-roadmap"],+ "planning_repository": "peach-mitao/peach-roadmap",+ "issue_aliases": {+ "peach-mitao/peach#69": "peach-mitao/peach-roadmap#1",+ "peach-mitao/peach#70": "peach-mitao/peach-roadmap#2",+ "peach-mitao/peach#71": "peach-mitao/peach-roadmap#3",+ "peach-mitao/peach#72": "peach-mitao/peach-roadmap#4",+ "peach-mitao/peach#73": "peach-mitao/peach-roadmap#5",+ "peach-mitao/peach#74": "peach-mitao/peach-roadmap#6",+ "peach-mitao/peach#75": "peach-mitao/peach-roadmap#7",+ "peach-mitao/peach#76": "peach-mitao/peach-roadmap#8",+ "peach-mitao/peach#77": "peach-mitao/peach-roadmap#9",+ "peach-mitao/peach#78": "peach-mitao/peach-roadmap#10",+ "peach-mitao/peach#79": "peach-mitao/peach-roadmap#11",+ "peach-mitao/peach#80": "peach-mitao/peach-roadmap#12",+ "peach-mitao/peach#81": "peach-mitao/peach-roadmap#13",+ "peach-mitao/peach#82": "peach-mitao/peach-roadmap#14",+ "peach-mitao/peach#83": "peach-mitao/peach-roadmap#15",+ "peach-mitao/peach#84": "peach-mitao/peach-roadmap#16",+ "peach-mitao/peach#85": "peach-mitao/peach-roadmap#17",+ "peach-mitao/peach#86": "peach-mitao/peach-roadmap#18",+ "peach-mitao/peach#87": "peach-mitao/peach-roadmap#19",+ "peach-mitao/peach#88": "peach-mitao/peach-roadmap#20",+ "peach-mitao/peach#89": "peach-mitao/peach-roadmap#21",+ "peach-mitao/peach#90": "peach-mitao/peach-roadmap#22",+ "peach-mitao/peach#67": "peach-mitao/peach-roadmap#23",+ "peach-mitao/peach#68": "peach-mitao/peach-roadmap#24"+ },"implementation_commits": {- "53": ["b2bdb529b536723138144cedc996c8530df2a336"],- "61": ["03eb94e22387e9ba3fc2401a2b5c73f64f525a44"],- "62": ["7887699b3ee4059325ace140744904a39bb5bb4a"],- "64": ["b8b809f37bb825d50c0cc53c8040016d71606218"],- "65": ["7cf62507ce6148af6e9b06af724b8764cf547cbf"]+ "peach-mitao/peach#53": ["b2bdb529b536723138144cedc996c8530df2a336"],+ "peach-mitao/peach#61": ["03eb94e22387e9ba3fc2401a2b5c73f64f525a44"],+ "peach-mitao/peach#62": ["7887699b3ee4059325ace140744904a39bb5bb4a"],+ "peach-mitao/peach#64": ["b8b809f37bb825d50c0cc53c8040016d71606218"],+ "peach-mitao/peach#65": ["7cf62507ce6148af6e9b06af724b8764cf547cbf"]}}diff --git a/.github/workflows/project-board.yml b/.github/workflows/project-board.ymlindex 052d8d073..a55a30261 100644--- a/.github/workflows/project-board.yml+++ b/.github/workflows/project-board.yml@@ -10,6 +10,8 @@ on:push:branches: [master]workflow_dispatch:+ schedule:+ - cron: '*/15 * * * *'permissions:contents: readdiff --git a/README.en.md b/README.en.mdindex c1e978ba1..b6844e07e 100644--- a/README.en.md+++ b/README.en.md@@ -11,7 +11,7 @@<a href="https://github.com/peach-mitao/peach/releases">Download for Windows</a> ·<a href="https://demo.peach.video">Live demo</a> ·<a href="https://github.com/peach-mitao/peach/releases/tag/intro-video">Intro video</a> ·- <a href="https://github.com/peach-mitao/peach/issues?q=is%3Aissue+is%3Aopen+-author%3Alongmeidao">Report a problem</a> ·+ <a href="https://github.com/peach-mitao/peach/issues">Report a problem</a> ·<a href="https://github.com/orgs/peach-mitao/projects/7/views/1">Requests board</a> ·<a href="https://github.com/orgs/peach-mitao/projects/7/views/3">Roadmap</a> ·<a href="#documentation">Documentation</a> ·@@ -102,7 +102,7 @@ See [Docker deployment](docs/DOCKER.md) for setup and supported configurations.## Reporting problems-Check [user feedback](https://github.com/peach-mitao/peach/issues?q=is%3Aissue+is%3Aopen+-author%3Alongmeidao), or [open an issue](https://github.com/peach-mitao/peach/issues/new/choose) with the version, steps, expected result and actual result. Hide credentials, LAN addresses and full paths in screenshots; do not upload databases or media. Report security issues privately through the [security policy](SECURITY.md).+Check [user feedback](https://github.com/peach-mitao/peach/issues), or [open an issue](https://github.com/peach-mitao/peach/issues/new/choose) with the version, steps, expected result and actual result. Hide credentials, LAN addresses and full paths in screenshots; do not upload databases or media. Report security issues privately through the [security policy](SECURITY.md).## Documentationdiff --git a/README.md b/README.mdindex 9086afe22..2b67bde83 100644--- a/README.md+++ b/README.md@@ -11,7 +11,7 @@<a href="https://github.com/peach-mitao/peach/releases">下载 Windows 版</a> ·<a href="https://demo.peach.video">在线演示</a> ·<a href="https://github.com/peach-mitao/peach/releases/tag/intro-video">介绍视频</a> ·- <a href="https://github.com/peach-mitao/peach/issues?q=is%3Aissue+is%3Aopen+-author%3Alongmeidao">问题反馈</a> ·+ <a href="https://github.com/peach-mitao/peach/issues">问题反馈</a> ·<a href="https://github.com/orgs/peach-mitao/projects/7/views/1">需求看板</a> ·<a href="https://github.com/orgs/peach-mitao/projects/7/views/3">路线图</a> ·<a href="#文档">文档</a> ·@@ -102,7 +102,7 @@ https://github.com/user-attachments/assets/a5610874-e611-41bb-be22-7d99f0d64b62## 问题反馈-先查看[用户反馈](https://github.com/peach-mitao/peach/issues?q=is%3Aissue+is%3Aopen+-author%3Alongmeidao),或[提交问题](https://github.com/peach-mitao/peach/issues/new/choose),附上版本、操作步骤、预期与实际结果。截图请遮掉凭据、局域网地址和完整路径,不要上传数据库或媒体;安全问题按[安全政策](SECURITY.md)私下报告。+先查看[用户反馈](https://github.com/peach-mitao/peach/issues),或[提交问题](https://github.com/peach-mitao/peach/issues/new/choose),附上版本、操作步骤、预期与实际结果。截图请遮掉凭据、局域网地址和完整路径,不要上传数据库或媒体;安全问题按[安全政策](SECURITY.md)私下报告。## 文档diff --git a/docs/PROJECT_BOARD.md b/docs/PROJECT_BOARD.mdindex 5f8c3e37a..c4f0170c0 100644--- a/docs/PROJECT_BOARD.md+++ b/docs/PROJECT_BOARD.md@@ -4,7 +4,7 @@「需求看板」展示全部项目需求,「维护者待办」和「用户反馈」分别按来源筛选,「路线图」展示计划阶段与优先级。README 顶部和仓库 Projects 提供入口。视图不改变公开范围,同一事项只维护一份。-Issue 列表也可按作者筛选:[维护者待办](https://github.com/peach-mitao/peach/issues?q=is%3Aissue+is%3Aopen+author%3Alongmeidao)、[用户反馈](https://github.com/peach-mitao/peach/issues?q=is%3Aissue+is%3Aopen+-author%3Alongmeidao)。登录后的 Issues 总览可以将相同查询保存为个人视图。+Issue 分别归属两个公开仓库:[用户反馈](https://github.com/peach-mitao/peach/issues)放在应用仓库,[维护者待办](https://github.com/peach-mitao/peach-roadmap/issues)放在规划仓库。应用仓库的 Issues 页直接呈现反馈,同一个公开 Project 汇总两边的事项。登录后的 Issues 总览可以按仓库查询并保存为个人视图。公开仓库的 Issue 始终按仓库权限可见,将它加入私有看板不会隐藏原 Issue。正式事项使用 GitHub Issue 编号;草稿保留已确认范围与优先级,相关事项使用可访问的链接说明关联。@@ -13,7 +13,7 @@ Issue 列表也可按作者筛选:[维护者待办](https://github.com/peach-m| 字段 | 含义 || --- | --- || Status | 待评估、待安排、进行中、待验证、已完成、已取消;PR 另有已关闭未合入,描述真实处理结果 |-| 来源 | 按配置的维护者账号识别为维护者待办,其余为用户反馈 |+| 来源 | 规划仓库为维护者待办,应用仓库为用户反馈;与提交者账号无关 || Priority | P0 紧急、P1 优先、P2 常规、P3 低优先级 || 计划阶段 | 近期、后续、探索;不构成交付日期承诺 || 等待条件 | 阻止下一步的具体条件;没有阻塞时留空 |@@ -26,21 +26,22 @@ PR 合入表示代码已集成。开放的需求进入待验证;完成验收## 自动同步-`.github/workflows/project-board.yml` 响应 Issue 开关和标签变化、PR 建立和合入、主线推送、Release 发布与变动。使用主线代码,不检出或执行外部 PR 的代码。所有同步串行执行,每次读取当前事实,重复执行不会重复建卡或推进状态。+应用仓库的 `.github/workflows/project-board.yml` 响应本仓库 Issue 开关和标签变化、PR 建立和合入、主线推送、Release 发布与变动,并每 15 分钟检查两个仓库。规划仓库的 Issue 开关与新建由定时检查同步。使用主线代码,不检出或执行外部 PR 的代码。所有同步串行执行,每次读取当前事实,重复执行不会重复建卡或推进状态。-- 公开路线图自动收录本仓库的新建 Issue,每轮补查开放事项,并同步真实状态与发布版本。PR 用于计算实现关联,内部草稿不复制到公开 Project。-- 来源按 Issue 作者与 `.github/project-board.json` 的维护者账号列表同步;分类视图使用同一份 Issue。+- 公开路线图自动收录两个配置仓库的 Issue;应用仓库补查开放事项,规划仓库补查全部状态,保证两次定时检查之间新建并关闭的事项也能收录。PR 用于计算实现关联,内部草稿不复制到公开 Project。+- 来源按 `.github/project-board.json` 配置的仓库同步;分类视图使用同一份 Issue。- 重新打开的事项按实际实现恢复为待安排或待验证,已关联开放 PR 的事项为进行中。-- PR 的 GitHub 关联和独立 `Refs #编号` 行建立实现关联;只处理本仓库引用。正文中普通提及某个编号不会被当成交付。+- 应用仓库 PR 的 GitHub 关联和独立关联行建立实现关联。规划任务使用 `Refs peach-mitao/peach-roadmap#编号`,应用反馈可使用 `Refs #编号`,也支持完整 Issue URL。只接受配置仓库,正文中普通提及某个编号不会被当成交付。+- 仓库名与编号共同标识 Issue;`issue_aliases` 保存迁移映射,使迁移前的关联行仍能指向对应任务。GitHub 原生转移保留历史讨论,原 Issue URL 自动跳转。- 已合入 PR 对应的开放需求进入待验证;`status:needs-info` 和 `status:needs-verification` 分别保留等待信息和验收的含义。- 从有下载制品的已发布 Release 中检查标签提交祖先关系,填写首次包含实现的版本。只有标签、失败构建和发布草稿均不算已发布。- 通过 Actions 的仓库令牌创建 Release 不会触发另一条 Release 工作流;发布工作流在上架后显式调用同一同步入口。- 不关闭 Issue,不合入 PR,不修改优先级、排期或归档状态。已归档事项不自动恢复。-历史直接集成而没有 PR 的实现,在 `.github/project-board.json` 登记完整提交 SHA;同步同样验证其是否属于主线和发布标签,不凭文字宣称完成。+历史直接集成而没有 PR 的实现,在 `.github/project-board.json` 的 `implementation_commits` 中以 `组织/仓库#编号` 为键登记完整提交 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)替代长期令牌。+组织 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 6cd077cc6..3cd60f740 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -2,6 +2,8 @@## GitHub 项目看板+用户反馈归属应用仓库 `peach-mitao/peach`,维护者项目任务归属 `peach-mitao/peach-roadmap`,共同使用一个公开 Project。集中在应用仓库处理事件并每 15 分钟补查规划仓库,凭据仅保留在应用仓库。Issue 关联使用仓库名与编号,迁移映射兼容已存在的关联行;交付版本始终按应用仓库的主线提交和发布制品核验。+看板同步复用 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 用户脚本添加diff --git a/scripts/project_board.py b/scripts/project_board.pyindex e6653e877..dc3d0d1fa 100644--- a/scripts/project_board.py+++ b/scripts/project_board.py@@ -56,18 +56,36 @@ def ancestor(commit, ref):return result.returncode == 0-def references(body, repository):+def references(body, repository, allowed=None):"""只接受独立的关联行,不把正文中随手提到的编号当成交付。"""- found = set()+ found, allowed = set(), {name.casefold(): name for name in (allowed or [repository])}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))+ matches = re.findall(r"(?:(\w[\w.-]*/[\w.-]+))?#(\d+)", line)+ matches += re.findall(r"https://github\.com/([\w.-]+/[\w.-]+)/issues/(\d+)", line)+ for repo, number in matches:+ repo = allowed.get((repo or repository).casefold())+ if repo:+ found.add(f"{repo}#{number}")return found+def issue_key(content):+ """仓库名与编号共同标识 Issue,避免跨仓库编号相同。"""+ return f'{content["repository"]["nameWithOwner"]}#{content["number"]}'+++def canonical(key, aliases):+ seen = set()+ while key in aliases:+ if key in seen:+ raise ValueError("Issue 迁移映射存在循环")+ seen.add(key)+ key = aliases[key]+ return key++def values(item):return {value["field"]["name"]: value.get("name", value.get("text", ""))for value in item.get("fieldValues", {}).get("nodes", []) if value}@@ -101,12 +119,12 @@ def decision(content, current, linked, published):return result-CONTENT = '''__typename ... on DraftIssue{id title} ... on Issue{id number title url state stateReason author{login}+CONTENT = '''__typename ... on DraftIssue{id title} ... on Issue{id number title url state stateReason repository{nameWithOwner}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}}'''+... on PullRequest{id number title url state merged mergeCommit{oid} body repository{nameWithOwner}+closingIssuesReferences(first:100){nodes{id number repository{nameWithOwner}}}}'''+PR_CONTENT = '''__typename id number title url state merged mergeCommit{oid} body repository{nameWithOwner}+closingIssuesReferences(first:100){nodes{id number repository{nameWithOwner}}}'''def read_project(project):@@ -132,29 +150,39 @@ pullRequests(first:100,after:$cursor,orderBy:{field:CREATED_AT,direction:DESC}){pageInfo{hasNextPage endCursor}}}}''', ("repository", "pullRequests"), owner=owner, name=name)-def issue_links(prs, repository):+def issue_links(prs, config):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)+ allowed = config.get("issue_repositories", [config["repository"]])+ keys = {issue_key(issue) for issue in pr["closingIssuesReferences"]["nodes"]+ if issue["repository"]["nameWithOwner"] in allowed}+ keys |= references(pr["body"], config["repository"], config.get("issue_repositories"))+ for key in {canonical(key, config.get("issue_aliases", {})) for key in keys}:+ linked.setdefault(key, []).append(pr)return linked+def incoming_issues(config):+ incoming = []+ for repository in config.get("issue_repositories", [config["repository"]]):+ owner, name = repository.split("/")+ incoming.extend(connection('''query($owner:String!,$name:String!,$states:[IssueState!],$cursor:String){repository(owner:$owner,name:$name){+issues(first:100,after:$cursor,states:$states){nodes{__typename id number title url state stateReason repository{nameWithOwner}+labels(first:100){nodes{name}}}pageInfo{hasNextPage endCursor}}}}''',+ ("repository", "issues"), owner=owner, name=name,+ states=None if repository == config.get("planning_repository") else ["OPEN"]))+ return incoming++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 author{login}-labels(first:100){nodes{name}}}pageInfo{hasNextPage endCursor}}}}''',- ("repository", "issues"), owner=owner, name=name)- tracked = {item["content"].get("number") for item in candidates.values()+ incoming = incoming_issues(config)+ tracked = {issue_key(item["content"]) 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"])]+ issue_key(issue) 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"]@@ -180,9 +208,9 @@ def published_releases(repository):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"], [])+ associated = [content] if is_pr else linked.get(issue_key(content), [])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 []+ commits += config.get("implementation_commits", {}).get(issue_key(content), []) 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}]@@ -205,7 +233,8 @@ def apply_fields(project, item, fields, desired, apply):continuefield = 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})+ changes.append({"repository": content["repository"]["nameWithOwner"], "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(@@ -222,7 +251,7 @@ 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)+ linked = issue_links(prs, config)candidates = {item["content"]["id"]: item for item in items if item.get("content")}include_incoming(config, candidates, prs, event, apply)releases = published_releases(repository)@@ -231,11 +260,12 @@ def reconcile(config, *, apply=False, event=None):content = item["content"]if item["isArchived"] or content["__typename"] not in {"Issue", "PullRequest"}:continue- if not content["url"].startswith(f"https://github.com/{repository}/"):+ content_repo = content["repository"]["nameWithOwner"]+ if content_repo not in config.get("issue_repositories", [repository]):continuedesired = delivery_fields(config, content, values(item), linked, releases)- if "来源" in fields and content.get("author"):- desired["来源"] = "维护者待办" if content["author"]["login"] in config.get("maintainers", []) else "用户反馈"+ if "来源" in fields:+ desired["来源"] = "维护者待办" if content_repo == config.get("planning_repository") else "用户反馈"changes.extend(apply_fields(project, item, fields, desired, apply))return changesdiff --git a/tests/test_scripts.py b/tests/test_scripts.pyindex 5995dc38a..05b462fb1 100644--- a/tests/test_scripts.py+++ b/tests/test_scripts.py@@ -59,7 +59,8 @@ class ProjectBoardTests(unittest.TestCase):cls.script = load_script("project_board")def issue(self, **changes):- return {"__typename": "Issue", "state": "OPEN", "labels": {"nodes": []}, **changes}+ return {"__typename": "Issue", "state": "OPEN", "labels": {"nodes": []},+ "repository": {"nameWithOwner": "peach-mitao/peach"}, **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"}@@ -83,7 +84,46 @@ class ProjectBoardTests(unittest.TestCase):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})+ self.assertEqual(self.script.references(body, "peach-mitao/peach"),+ {f"peach-mitao/peach#{number}" for number in (65, 66, 68)})++ def test_migrated_references_deduplicate_without_cross_repository_number_collision(self):+ main, planning = "peach-mitao/peach", "peach-mitao/peach-roadmap"+ config = {"repository": main, "issue_repositories": [main, planning],+ "issue_aliases": {f"{main}#70": f"{planning}#1"}}+ pr = {"state": "MERGED", "merged": True, "mergeCommit": {"oid": "a" * 40}, "url": "https://example.test/pr",+ "body": f"Refs #70, {planning}#1, other/repo#1\nRefs https://github.com/{planning}/issues/1",+ "closingIssuesReferences": {"nodes": [self.issue(number=1, repository={"nameWithOwner": planning}),+ self.issue(number=1, repository={"nameWithOwner": "other/repo"})]}}+ linked = self.script.issue_links([pr], config)+ self.assertEqual(linked, {f"{planning}#1": [pr]})+ config["implementation_commits"] = {f"{main}#1": ["b" * 40]}+ with mock.patch.object(self.script, "ancestor") as ancestry:+ untouched = self.script.delivery_fields(config, self.issue(number=1, repository={"nameWithOwner": planning}), {}, {}, [])+ self.assertEqual(untouched["交付进度"], "未关联实现")+ ancestry.assert_not_called()+ release = {"tag_name": "v1.0", "html_url": "https://example.test/v1.0"}+ with mock.patch.object(self.script, "ancestor", return_value=True) as ancestry:+ result = self.script.delivery_fields(config, self.issue(number=1, repository={"nameWithOwner": planning}), {}, linked, [release])+ self.assertEqual(result["发布版本"], "v1.0")+ self.assertEqual(result["实现关联"], pr["url"])+ self.assertTrue(all(call.args[0] == "a" * 40 for call in ancestry.call_args_list))+ with mock.patch.object(self.script, "ancestor") as ancestry:+ result = self.script.delivery_fields(config, self.issue(number=1), {}, linked, [])+ self.assertEqual(result["交付进度"], "已合入待发布")+ ancestry.assert_called_once_with("b" * 40, "origin/master")++ def test_planning_poll_includes_closed_issues_and_alias_cycles_fail(self):+ main, planning = "peach-mitao/peach", "peach-mitao/peach-roadmap"+ closed = self.issue(id="closed", state="CLOSED")+ with mock.patch.object(self.script, "connection", side_effect=[[], [closed]]) as read:+ result = self.script.incoming_issues({"repository": main, "planning_repository": planning,+ "issue_repositories": [main, planning]})+ self.assertEqual(result, [closed])+ self.assertEqual(read.call_args_list[0].kwargs["states"], ["OPEN"])+ self.assertIsNone(read.call_args_list[1].kwargs["states"])+ with self.assertRaisesRegex(ValueError, "循环"):+ self.script.canonical("a", {"a": "b", "b": "a"})def test_pr_closure_is_distinct_from_merge(self):pr = {"__typename": "PullRequest", "state": "CLOSED", "merged": False}@@ -125,9 +165,10 @@ class ProjectBoardTests(unittest.TestCase):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=True)- maintained = self.script.reconcile({"project_id": "project", "repository": "peach-mitao/peach", "maintainers": ["visitor"],- "implementation_commits": {"65": [commit]}}, apply=False)+ "implementation_commits": {"peach-mitao/peach#65": [commit]}}, apply=True)+ maintained = self.script.reconcile({"project_id": "project", "repository": "peach-mitao/peach",+ "planning_repository": "peach-mitao/peach",+ "implementation_commits": {"peach-mitao/peach#65": [commit]}}, apply=False)self.assertEqual({change["number"] for change in changes}, {65})actual = {change["field"]: change["value"] for change in changes}self.assertEqual(actual["发布版本"], "v0.43.0")