Peach: Local-first video metadata scraper and media manager.
fix(github): 命令行提交、既没有类型也没有模板章节的 issue 一律关闭
longmeidao1278a4453e6f
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 8f84dba82..6fa787c54 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -17,9 +17,9 @@ Issue 按 [`.github/ISSUE_TEMPLATE/`](.github/ISSUE_TEMPLATE/) 的模板写:gh issue create --repo peach-mitao/peach --title "<标题>" --type Bug --body-file <填好的模板>```-建议把 `Bug` 换成 `Feature`;没有设置类型的权限时省略 `--type`,按模板章节写的 issue 会自动补上类型。正文写给维护者和其他用户看,用通用技术说法;`AGENTS.md` 与技能里的术语和交付格式只用于改代码,不用于 issue。没有模板章节、又套用这些内部用语的 issue 会被自动关闭,按模板补齐后自动重开。+建议把 `Bug` 换成 `Feature`;没有设置类型的权限时省略 `--type`,按模板章节写的 issue 会自动补上类型。正文写给维护者和其他用户看,用通用技术说法;`AGENTS.md` 与技能里的术语和交付格式只用于改代码,不用于 issue。用命令行或 API 提交、既没有类型也没有模板章节的 issue 会被自动关闭,按模板补齐章节后自动重开。-Write issues with the templates in [`.github/ISSUE_TEMPLATE/`](.github/ISSUE_TEMPLATE/): `bug_report.md` for bugs, `feature_request.md` for features. Keep the template headings in order and fill in each one; drop optional sections you have nothing for, and put extra material such as a root-cause analysis after the template sections. The web form under New issue is the easiest path. When an AI tool or the command line submits the issue, copy the template file, remove the leading `---` block and the `<!-- -->` comments, fill it in, and submit it with the command above; use `--type Feature` for features, and leave out `--type` if you lack permission to set it: issues that follow a template get their type automatically. Write for maintainers and other users in plain technical language; the terms and delivery format in `AGENTS.md` and the skills are for code changes, not issues. Issues that skip the template sections and use those internal terms are closed automatically, and reopen once the sections are filled in.+Write issues with the templates in [`.github/ISSUE_TEMPLATE/`](.github/ISSUE_TEMPLATE/): `bug_report.md` for bugs, `feature_request.md` for features. Keep the template headings in order and fill in each one; drop optional sections you have nothing for, and put extra material such as a root-cause analysis after the template sections. The web form under New issue is the easiest path. When an AI tool or the command line submits the issue, copy the template file, remove the leading `---` block and the `<!-- -->` comments, fill it in, and submit it with the command above; use `--type Feature` for features, and leave out `--type` if you lack permission to set it: issues that follow a template get their type automatically. Write for maintainers and other users in plain technical language; the terms and delivery format in `AGENTS.md` and the skills are for code changes, not issues. Issues submitted through the command line or the API with neither a type nor the template sections are closed automatically, and reopen once the sections are filled in.公开截图、录屏和附件使用不含露骨画面的演示资料,并遮盖隐私信息;不要上传影片、封面原图或数据库。公开内容与素材许可要求见[文档规范](docs/WRITING.md#公开与私有记录)。diff --git a/scripts/issue_intake.py b/scripts/issue_intake.pyindex 172bf0c27..a34a00406 100644--- a/scripts/issue_intake.py+++ b/scripts/issue_intake.py@@ -1,9 +1,9 @@"""外部 issue 的模板检查:让命令行和 API 提交的 issue 与网页模板提交的结果一致。-网页「New issue」按模板提交时会带上模板的 Issue Type;用 `gh` 或 API 提交则不经过模板。-作者不是维护者、也没有 Issue Type 的新 issue 按下列规则处理:正文含有某个模板的章节,-补上那个模板的 Issue Type;缺少模板章节又套用了 `AGENTS.md` 与技能里的交付用语,关闭;-按模板补齐章节后重开并补上类型。GitHub 写操作由 `.github/workflows/issue-intake.yml` 完成,+网页「New issue」按模板提交时,即使删光模板文字也会带上模板的 Issue Type;用 `gh` 或 API+提交则不经过模板。作者不是维护者、也没有 Issue Type 的新 issue 按下列规则处理:正文含有+某个模板的章节,补上那个模板的 Issue Type;缺少模板章节,关闭;按模板补齐章节后重开并+补上类型。GitHub 写操作由 `.github/workflows/issue-intake.yml` 完成,本脚本只输出 `keep`、`close`、`type <类型>` 或 `reopen <类型>`。"""from __future__ import annotations@@ -18,9 +18,6 @@ ROOT = Path(__file__).resolve().parents[1]TEMPLATES = ROOT / ".github/ISSUE_TEMPLATE"LABEL = "status:needs-template"MAINTAINERS = frozenset({"OWNER", "MEMBER", "COLLABORATOR"})-# 智能体规则里的交付用语,用户自己描述问题时很少写到。-INTERNAL_TERMS = ("账本", "真相字段", "影响面", "落库", "复核产物", "兼容投影", "授权边界",- "合成样本", "验收", "交接", "明确不做", "分批交付", "隔离工作树")HEADING = re.compile(r"^ {0,3}#{1,6}\s*(.+?)\s*#*\s*$", re.M)TYPE_LINE = re.compile(r"^type:\s*(\S+)\s*$", re.M)OPTIONAL = re.compile(r"[((][^))]*[))]")@@ -64,10 +61,6 @@ def matched_type(body: str, templates: list[Template] | None = None) -> str | Noreturn None-def internal_terms(body: str) -> list[str]:- return [term for term in INTERNAL_TERMS if term in (body or "")]--def verdict(payload: dict, templates: list[Template] | None = None) -> str:issue = payload.get("issue") or {}if issue.get("pull_request") or (issue.get("user") or {}).get("type") == "Bot" \@@ -83,7 +76,7 @@ def verdict(payload: dict, templates: list[Template] | None = None) -> str:return "keep"if kind:return f"type {kind}"- return "close" if action == "opened" and internal_terms(body) else "keep"+ return "close" if action == "opened" else "keep"def main(argv: list[str] | None = None) -> int:diff --git a/tests/test_issue_intake.py b/tests/test_issue_intake.pyindex a864b4f50..d53513d01 100644--- a/tests/test_issue_intake.py+++ b/tests/test_issue_intake.py@@ -36,14 +36,16 @@ class IssueIntakeTests(unittest.TestCase):self.assertEqual(issue_intake.verdict(event(body=BUG_BODY)), "type Bug")self.assertEqual(issue_intake.verdict(event("edited", BUG_BODY)), "type Bug")- def test_untyped_issue_without_sections_in_rule_jargon_is_closed(self):- self.assertEqual(issue_intake.verdict(event()), "close")+ def test_untyped_new_issue_without_template_sections_is_closed(self):+ for body in (JARGON_BODY, "希望垃圾文件可以批量删除", ""):+ with self.subTest(body=body[:12]):+ self.assertEqual(issue_intake.verdict(event(body=body)), "close")self.assertEqual(issue_intake.verdict(event("edited")), "keep")- def test_web_form_issues_and_plain_free_text_are_left_alone(self):+ def test_web_form_issues_keep_their_text_even_without_sections(self):for payload in (event(type={"name": "Feature"}),event(body=FEATURE_BODY, type={"name": "Feature"}),- event(body="希望垃圾文件可以批量删除")):+ event(body="希望垃圾文件可以批量删除", type={"name": "Feature"})):with self.subTest(body=payload["issue"]["body"][:12]):self.assertEqual(issue_intake.verdict(payload), "keep")