docs(version): 补齐270条历史开发版本说明
build / build (push) Successful in 1m29s

按权威 version→commit 映射,为缺失开发版本增加 exact-SHA CHANGELOG 块。
正文采用该提交新增 CHANGELOG 或真实 commit body/diff 归纳,已有82条不改。
新增270条绑定验收与错SHA拒绝测试,不改变版本计算与同步实现。
This commit is contained in:
姚章浩
2026-11-04 16:20:09 +08:00
parent 2a2e98bd8e
commit e735ae603d
4 changed files with 6130 additions and 2 deletions
+4992
View File
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,54 @@
package versionhistory
import (
"encoding/json"
"os"
"strings"
"testing"
"knowledge-governance/internal/governance"
)
func TestAllHistoricalDevelopmentNotesBindExactCommit(t *testing.T) {
changelogBytes, err := os.ReadFile("../../CHANGELOG.md")
if err != nil {
t.Fatal(err)
}
changelog := string(changelogBytes)
fixtureBytes, err := os.ReadFile("testdata/development_notes_history.json")
if err != nil {
t.Fatal(err)
}
var entries []struct {
Version string `json:"version"`
SHA string `json:"sha"`
}
if err := json.Unmarshal(fixtureBytes, &entries); err != nil {
t.Fatal(err)
}
if len(entries) != 270 {
t.Fatalf("history fixture must contain 270 missing development versions, got %d", len(entries))
}
seen := map[string]string{}
wrong := strings.Repeat("f", 40)
for _, entry := range entries {
if prev, ok := seen[entry.Version]; ok && prev != entry.SHA {
t.Fatalf("version %s bound to multiple commits", entry.Version)
}
seen[entry.Version] = entry.SHA
notes := governance.ExtractDevelopmentNotesForCommit(changelog, entry.Version, entry.SHA)
if strings.TrimSpace(notes) == "" {
t.Fatalf("version %s sha %s has no exact-SHA notes", entry.Version, entry.SHA)
}
if strings.Contains(notes, "目标提交:"+entry.SHA) == false {
t.Fatalf("version %s body does not carry its exact target line", entry.Version)
}
if leaked := governance.ExtractDevelopmentNotesForCommit(changelog, entry.Version, wrong); leaked != "" {
t.Fatalf("version %s notes leaked to wrong SHA: %q", entry.Version, leaked)
}
}
// 相邻/前缀版本不能互相命中。
if notes := governance.ExtractDevelopmentNotesForCommit(changelog, "0.1.35", entries[0].SHA); notes != "" {
t.Fatalf("0.1.35 leaked notes for another commit: %q", notes)
}
}
@@ -70,8 +70,8 @@ func TestRealChangelogDevelopmentNotes(t *testing.T) {
if notes == "" || !strings.Contains(notes, tc.want) {
t.Fatalf("real CHANGELOG %s notes missing: %q", tc.version, notes)
}
if governance.ExtractDevelopmentNotes(changelog, "0.1.35") != "" {
t.Fatal("prefix version matched a longer version")
if other := governance.ExtractDevelopmentNotes(changelog, "0.1.35"); strings.Contains(other, "首次同步可复用") || strings.Contains(other, "索引预检") {
t.Fatalf("0.1.35 matched a longer version's body: %q", other)
}
}
}
File diff suppressed because it is too large Load Diff