现象(主人反馈):点「查看提交」打开是空白页。原因:链接用的是**抓取用的内网地址** (`http://192.168.50.223:3000/...`),内网外的浏览器到不了;而公网地址 `https://gitea.zheromiku.top/...` 实测 200。另外 tag 证据里**根本没有 url**, 页面渲染出空 `href`,点下去像"没反应"。 修复: - 新增 `VERSION_HISTORY_LINK_ORIGIN`(页面链接 origin,公网;留空 = 与抓取 origin 相同): 抓取仍匿名走内网白名单地址,**给人点的链接**用公网 origin 拼 —— 两者本就不该共用一个地址; 校验必须是干净的 http(s) 绝对地址。 - tag 证据补 `url`(`<link origin>/<repo>/src/tag/<name>`),并在前端**没有链接就不渲染**该按钮。 - 测试:客户端(LinkOrigin 生效 / 未配时退回 / 非法拒绝)、规则(tag 链接写入证据 / 无基址不编链接)、 前端(有链接才渲染「查看 tag」)。 验证:make verify 15/15;真实链路重同步后库里 commit_url = `https://gitea.zheromiku.top/...`(200)、 release_tags 带 url。
This commit is contained in:
@@ -104,6 +104,8 @@ type Source interface {
|
||||
CommitURLBase() string
|
||||
ListCommits(ctx context.Context, page, limit int) ([]RawCommit, int, error)
|
||||
ListTags(ctx context.Context) ([]RawTag, error)
|
||||
// TagURLBase 是 tag 链接的基址(给人看的 origin,可能与抓取 origin 不同)。
|
||||
TagURLBase() string
|
||||
ReadFile(ctx context.Context, sha, path string) (string, error)
|
||||
// BranchHeadSHA 读分支 HEAD;读不到不算致命(退回"提交列表里最新的那条")。
|
||||
BranchHeadSHA(ctx context.Context, branch string) (string, error)
|
||||
@@ -203,7 +205,8 @@ func (s *Syncer) Sync(ctx context.Context, jobID, triggeredBy string) (governanc
|
||||
}
|
||||
|
||||
derived := DeriveVersions(DeriveInput{RepoKey: s.repoKey, CommitURLBase: s.source.CommitURLBase(),
|
||||
Commits: commits, Tags: tags, SnapshotID: runID,
|
||||
TagURLBase: s.source.TagURLBase(),
|
||||
Commits: commits, Tags: tags, SnapshotID: runID,
|
||||
Changelog: func(sha string) (string, error) {
|
||||
return s.source.ReadFile(ctx, sha, s.changelog)
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user