013ce4a24e
build / build (push) Successful in 1m3s
收录 main、注释开发快照和完整运行 SHA;开发说明绑定原提交,补记 0.1.1–0.1.25。 进行中同步按仓库合并,完成后重新执行;启动入队,部署脚本读回版本证据。 开发快照独立于正式标签与 Release,既有冲突标签不移动。 已运行:整仓 make verify,Go 673 通过、前端 274 通过,92 个已声明可选跳过,必需跳过 0。 隔离 PostgreSQL 重复同步队列用例及 -race 通过;未更新现有 8088、未修改生产问答。
59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package versionhistory
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"knowledge-governance/internal/governance"
|
|
"sort"
|
|
"strings"
|
|
)
|
|
|
|
func (s *Syncer) includeDeliveredCommits(ctx context.Context, commits []RawCommit, tags []RawTag) ([]RawCommit, error) {
|
|
seen := map[string]bool{}
|
|
for _, c := range commits {
|
|
seen[c.SHA] = true
|
|
}
|
|
refs := append([]string{}, s.targetSHAs...)
|
|
snapshots := []RawTag{}
|
|
for _, tag := range tags {
|
|
if tag.Annotated && strings.HasPrefix(tag.Name, "snapshot/v") && governance.SemverValid(strings.TrimPrefix(tag.Name, "snapshot/v")) {
|
|
snapshots = append(snapshots, tag)
|
|
}
|
|
}
|
|
sort.Slice(snapshots, func(i, j int) bool {
|
|
return governance.CompareSemver(strings.TrimPrefix(snapshots[i].Name, "snapshot/v"), strings.TrimPrefix(snapshots[j].Name, "snapshot/v")) > 0
|
|
})
|
|
for _, tag := range snapshots {
|
|
refs = append(refs, tag.TargetSHA)
|
|
}
|
|
for _, ref := range refs {
|
|
if seen[ref] {
|
|
continue
|
|
}
|
|
if !fullSHA.MatchString(ref) {
|
|
return nil, fmt.Errorf("开发快照缺少完整提交身份")
|
|
}
|
|
extra, total, e := s.fetchCommitsAt(ctx, ref)
|
|
if e != nil {
|
|
return nil, e
|
|
}
|
|
if total > 0 && len(extra) != total {
|
|
return nil, codeError{code: ErrorCodeCountMismatch, message: "开发快照提交历史不完整"}
|
|
}
|
|
found := false
|
|
for _, c := range extra {
|
|
if c.SHA == ref {
|
|
found = true
|
|
}
|
|
if !seen[c.SHA] {
|
|
seen[c.SHA] = true
|
|
commits = append(commits, c)
|
|
}
|
|
}
|
|
if !found {
|
|
return nil, codeError{code: ErrorCodeIncompletePages, message: "开发快照目标没有被取回"}
|
|
}
|
|
}
|
|
return commits, nil
|
|
}
|