74ba737b1e
build / build (push) Successful in 1m4s
历史分支中存在两条开发号 0.1.1;归档选择按 SHA 匹配,保留原编号与冲突标签。 增加同号前置说明遮蔽及错 SHA 不复用回归,标签计划使用相同精确选择方式。 已运行:定向 Go 测试、快照工具临时仓正反例及整仓 make verify;未部署。
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package governance
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// 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 ""
|
|
}
|
|
lines := strings.Split(changelog, "\n")
|
|
prefix := "## 开发快照 snapshot/v" + version + " - "
|
|
for i, line := range lines {
|
|
if strings.HasPrefix(line, prefix) {
|
|
end := len(lines)
|
|
for j := i + 1; j < len(lines); j++ {
|
|
if strings.HasPrefix(lines[j], "## ") {
|
|
end = j
|
|
break
|
|
}
|
|
}
|
|
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 ""
|
|
}
|