mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-28 22:39:05 +08:00
fix github links for +incompatible versions
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user