fix(version): 按完整提交区分同号历史开发说明
build / build (push) Successful in 1m4s

历史分支中存在两条开发号 0.1.1;归档选择按 SHA 匹配,保留原编号与冲突标签。
增加同号前置说明遮蔽及错 SHA 不复用回归,标签计划使用相同精确选择方式。
已运行:定向 Go 测试、快照工具临时仓正反例及整仓 make verify;未部署。
This commit is contained in:
姚章浩
2026-10-18 18:18:43 +08:00
parent 013ce4a24e
commit 74ba737b1e
5 changed files with 38 additions and 10 deletions
+15 -1
View File
@@ -6,6 +6,12 @@ import (
// Development headings cannot replace the formal release baseline.
func ExtractDevelopmentNotes(changelog, version string) string {
return developmentNotes(changelog, version, "")
}
func ExtractDevelopmentNotesForCommit(changelog, version, sha string) string {
return developmentNotes(changelog, version, sha)
}
func developmentNotes(changelog, version, sha string) string {
if !SemverValid(version) {
return ""
}
@@ -20,7 +26,15 @@ func ExtractDevelopmentNotes(changelog, version string) string {
break
}
}
return strings.TrimSpace(strings.Join(lines[i+1:end], "\n"))
body := strings.TrimSpace(strings.Join(lines[i+1:end], "\n"))
if sha == "" {
return body
}
for _, field := range lines[i+1 : end] {
if strings.TrimSpace(field) == "目标提交:"+sha {
return body
}
}
}
}
return ""
@@ -55,6 +55,14 @@ func TestHistoricDevelopmentArchiveBindsExactCommit(t *testing.T) {
t.Fatal("archived notes missing")
}
}
// Parallel branch histories may legitimately have the same derived number.
input.DeliveryArchive = strings.ReplaceAll(archive, shaB, strings.Repeat("c", 40)) + "\n" + archive
result = DeriveVersions(input)
for _, v := range result.Records {
if v.CommitSHA == shaB && !strings.Contains(v.ReleaseNotes, "historic delivery notes") {
t.Fatal("same-number archive hid notes for exact commit")
}
}
input.DeliveryArchive = strings.ReplaceAll(archive, shaB, strings.Repeat("c", 40))
result = DeriveVersions(input)
for _, v := range result.Records {
+1 -4
View File
@@ -198,10 +198,7 @@ func DeriveVersions(in DeriveInput) DeriveResult {
} else if kind == governance.RecordKindDevelopment {
record.ReleaseNotes = governance.ExtractDevelopmentNotes(changelog, label)
if record.ReleaseNotes == "" {
archived := governance.ExtractDevelopmentNotes(in.DeliveryArchive, label)
if strings.Contains(archived, "目标提交:"+commit.SHA) {
record.ReleaseNotes = archived
}
record.ReleaseNotes = governance.ExtractDevelopmentNotesForCommit(in.DeliveryArchive, label, commit.SHA)
}
if record.ReleaseNotes == "" {
for _, tag := range tagsByTarget[commit.SHA] {