t177 更正:取回 08-02 的原版修法,撤掉我重寫的次級版本
【leo 08-04 質問】「這不是先前改過為什麼又出現?你去查看 wiki,是不是你沒看 wiki 就改?」
——**是。查證屬實,而且比沒查更糟。**
【事實】08-02 commit `dde7a5b` 已完整修過這個 bug(t170 daemon 側),
但它**只在 `fix/cis-round3-landing-favicon` 分支**,`feat/daemon` 不含它。
我在 feat/daemon 上看到沒修過的舊 code,就當新 bug 從頭修了一遍。
【而且我修得比原版差】
08-02 原版:isSemverLike 辨格式 → compareSemver **逐段整數比較**
(能擋 "1.10.0" < "1.9.0" 這個經典坑)+ minCloudRelease 最低版本常數
我今天版: 只判「是不是 semver」,是就放行 ⇒ 無法表達「semver 世代的最低相容版本」
⇒ 本 commit **取回 08-02 原版**(git checkout dde7a5b -- ...),
刪掉我另建的重複測試檔 cloudversion_test.go,改用原版在 main_test.go 的 8 則。
【測試】兩模組全綠;8 則逐項通過,含「semver 1.10.0 比 1.9.0 新(防字串比較)」
——那則正是我的版本表達不出來的。
【病根】hook 給的是 wiki grep 命中行,而那幾行**不含「已修過」的線索**
(關鍵字 compareSemver/isSemverLike 不在搜尋詞裡)。我把「hook 沒提」當成「沒人修過」,
且跳過了 `git log --all -S` 這個五秒就能做的機械檢查。
⇒ 已在頂層 InkStoneCo 補 hook:改檔時一併列出**該檔在所有分支的近期 commit**。
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -590,3 +590,31 @@ func TestAddOrUpdateAccount_IgnoresRemoteLLMSettings(t *testing.T) {
|
||||
t.Errorf("連線欄位仍應更新,got namespace=%q", cfg.Accounts[0].Namespace)
|
||||
}
|
||||
}
|
||||
|
||||
// 🔴 t177/08-02 迴歸守衛:版本比較不可退回字串比較(wiki 事故 D)。
|
||||
// 這個 bug 有**兩份**(本函式+collector/cloud_version.go)——
|
||||
// 改動版本號格式時,**兩份測試都要綠**。
|
||||
func TestTrayCloudVersionStale(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
version string
|
||||
checkOK bool
|
||||
wantStale bool
|
||||
}{
|
||||
{"semver 最新版不該被判過舊", "1.4.1", true, false},
|
||||
{"semver 剛好達標", "1.4.0", true, false},
|
||||
{"semver 過舊要提示", "1.3.9", true, true},
|
||||
{"semver 1.10.0 比 1.9.0 新(防字串比較)", "1.10.0", true, false},
|
||||
{"舊格式過舊仍要判過舊(相容)", "2026-07-01+deadbee", true, true},
|
||||
{"舊格式達標", "2026-07-28+abc1234", true, false},
|
||||
{"空版本(老實例)", "", true, true},
|
||||
{"health 不可達→不判定(呼叫端另顯示查不到)", "", false, false},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := trayCloudVersionStale(tc.version, tc.checkOK); got != tc.wantStale {
|
||||
t.Errorf("trayCloudVersionStale(%q, %v) = %v,want %v", tc.version, tc.checkOK, got, tc.wantStale)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user