diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bd2058..231dd9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ All notable changes. Format: [Keep a Changelog](https://keepachangelog.com/); versioning: SemVer. ## [Unreleased] +### Fixed +- `new-project.sh`: 坑6 升级地雷——Status 选项已一致时跳过 `updateProjectV2Field` 重交(实测重交会清空全部条目已选值,升级有数据的仓库必踩;沙盒复现验证) ### Added - `new-project.sh` 注入 AGENTS.md 小节(Codex 等读 AGENTS.md 的工具入口;与 CLAUDE.md 共用 `merge_section` 小节级幂等合并);`install.sh` 建兼容软链 `~/devledger`;模板路径统一为标准安装路径 `~/.agents/skills/devledger`(他人机器引用不再断裂) ### Docs diff --git a/scripts/new-project.sh b/scripts/new-project.sh index df05e5d..c5be43f 100755 --- a/scripts/new-project.sh +++ b/scripts/new-project.sh @@ -112,13 +112,20 @@ ALL_FIELDS=$(gql "query { node(id: \"${PJ_ID}\") { ... on ProjectV2 { fields(fir STATUS_ID=$(jq -r '.[] | select(.name == "Status") | .id' <<<"${ALL_FIELDS}") TITLE_ID=$(jq -r '.[] | select(.name == "Title") | .id' <<<"${ALL_FIELDS}") ASSIGNEE_ID=$(jq -r '.[] | select(.name == "Assignees") | .id' <<<"${ALL_FIELDS}") -gql "mutation { updateProjectV2Field(input: {fieldId: \"${STATUS_ID}\", singleSelectOptions: [ - {name: \"待办\", color: GRAY, description: \"\"}, - {name: \"开发中\", color: YELLOW, description: \"\"}, - {name: \"已完成\", color: GREEN, description: \"\"} -]}) { projectV2Field { ... on ProjectV2SingleSelectField { options { name } } } } }" >/dev/null -say " Status=${STATUS_ID} 选项: 待办/开发中/已完成" -sleep "${PACE}" +# 坑6:singleSelectOptions 重交会清空全部条目已选值——选项已一致时必须跳过 mutation(读回比对) +CURRENT_OPTS=$(gql "query { node(id: \"${STATUS_ID}\") { ... on ProjectV2SingleSelectField { options { name } } } }" \ + --jq '[.data.node.options[].name] | join(",")') +if [ "${CURRENT_OPTS}" = "待办,开发中,已完成" ]; then + say " Status 选项已是中文,跳过(坑6:重交会清空条目已选值)" +else + gql "mutation { updateProjectV2Field(input: {fieldId: \"${STATUS_ID}\", singleSelectOptions: [ + {name: \"待办\", color: GRAY, description: \"\"}, + {name: \"开发中\", color: YELLOW, description: \"\"}, + {name: \"已完成\", color: GREEN, description: \"\"} + ]}) { projectV2Field { ... on ProjectV2SingleSelectField { options { name } } } } }" >/dev/null + say " Status=${STATUS_ID} 选项: 待办/开发中/已完成" + sleep "${PACE}" +fi # ---------- 4. View 1 配可见列(API 建的字段不会自动进视图) ---------- say "配置 View 1 可见列" diff --git a/tests/test_rollout_readiness.py b/tests/test_rollout_readiness.py index dba4214..a81f92e 100644 --- a/tests/test_rollout_readiness.py +++ b/tests/test_rollout_readiness.py @@ -42,3 +42,8 @@ def test_example_ledger_has_reqperson(self): def test_export_no_dead_code(self): """export 中不留 no-op 替换死代码""" self.assertNotIn('"query($cursor: String)", "query($cursor: String)"', EXPORT) + + def test_status_options_skip_when_identical(self): + """坑6:Status 选项重交会清空全部条目已选值——已一致必须跳过 mutation(读回比对)""" + self.assertIn("已是中文", NP) + self.assertRegex(NP, r"CURRENT_OPTS=\$\(") \ No newline at end of file