fix github links for +incompatible versions

This commit is contained in:
Shawn Smith
2021-11-30 13:45:48 +09:00
parent 0874bef40a
commit 114dbff3bd
2 changed files with 5 additions and 0 deletions

View File

@@ -251,6 +251,10 @@ func fileURL(dir, filename string) string {
ver = strings.Split(ver, "-")[2]
}
if strings.Contains(ver, "+incompatible") {
ver = strings.TrimSuffix(ver, "+incompatible")
}
return fmt.Sprintf("https://%s/blob/%s/%s", base, ver, f)
}

View File

@@ -71,6 +71,7 @@ func TestFileURL(t *testing.T) {
}{
{"_repos/src/github.com/foo/testrepo@v0.1.0/bar/baz.go", "/github.com/foo/testrepo@v0.1.0/bar/baz.go", "https://github.com/foo/testrepo/blob/v0.1.0/bar/baz.go"},
{"_repos/src/github.com/foo/testrepo@v0.0.0-20211126063219-a5e10ccf946a/bar/baz.go", "/github.com/foo/testrepo@v0.0.0-20211126063219-a5e10ccf946a/bar/baz.go", "https://github.com/foo/testrepo/blob/a5e10ccf946a/bar/baz.go"},
{"_repos/src/github.com/foo/testrepo@v20.10.11+incompatible/bar/baz.go", "/github.com/foo/testrepo@v20.10.11+incompatible/bar/baz.go", "https://github.com/foo/testrepo/blob/v20.10.11/bar/baz.go"},
}
for _, tt := range cases {