现象(主人反馈):点「查看提交」打开是空白页。原因:链接用的是**抓取用的内网地址** (`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:
@@ -177,6 +177,25 @@ func TestDeriveVersionsPicksUpTagAddedAfterwards(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeriveVersionsFillsTagLinksForHumans(t *testing.T) {
|
||||
commits := []RawCommit{commit("A", nil, 1)}
|
||||
tags := []RawTag{{Name: "v0.1.0", TargetSHA: "A", Annotated: true}}
|
||||
derived := DeriveVersions(DeriveInput{RepoKey: "repo", Commits: commits, Tags: tags,
|
||||
CommitURLBase: "https://gitea.example/o/r/commit/",
|
||||
TagURLBase: "https://gitea.example/o/r/src/tag/",
|
||||
Changelog: readerFor(map[string]string{"A": "0.1.0"})})
|
||||
record := find(t, derived.Records, "A")
|
||||
if len(record.ReleaseTags) != 1 || record.ReleaseTags[0].URL != "https://gitea.example/o/r/src/tag/v0.1.0" {
|
||||
t.Fatalf("tag 必须带可点的链接:%+v", record.ReleaseTags)
|
||||
}
|
||||
// 不给 TagURLBase ⇒ 不下发链接(页面据此不渲染空的 tag 链接)
|
||||
bare := DeriveVersions(DeriveInput{RepoKey: "repo", Commits: commits, Tags: tags,
|
||||
Changelog: readerFor(map[string]string{"A": "0.1.0"})})
|
||||
if url := find(t, bare.Records, "A").ReleaseTags[0].URL; url != "" {
|
||||
t.Fatalf("没有基址时不该编链接:%q", url)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeriveVersionsSortsDeterministicallyForPaging(t *testing.T) {
|
||||
sameTime := at(9)
|
||||
commits := []RawCommit{
|
||||
|
||||
Reference in New Issue
Block a user