Correctly create azure git links. (#1743)

This commit is contained in:
ahrav 2023-09-01 10:38:51 -07:00 committed by GitHub
parent 000065b225
commit c9e6086644
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -132,9 +132,9 @@ func GenerateLink(repo, commit, file string, line int64) string {
return baseLink return baseLink
case providerAzure: case providerAzure:
baseLink := repo + "?path=" + file + "&version=GB" + commit baseLink := repo + "/commit/" + commit + "/" + file
if line > 0 { if line > 0 {
baseLink += "&line=" + strconv.FormatInt(line, 10) baseLink += "?line=" + strconv.FormatInt(line, 10)
} }
return baseLink return baseLink

View file

@ -148,7 +148,7 @@ func TestGenerateLink(t *testing.T) {
commit: "abcdef", commit: "abcdef",
file: "main.go", file: "main.go",
}, },
want: "https://dev.azure.com/org/project/_git/repo?path=main.go&version=GBabcdef", want: "https://dev.azure.com/org/project/_git/repo/commit/abcdef/main.go",
}, },
{ {
name: "Azure link gen with line", name: "Azure link gen with line",
@ -158,7 +158,7 @@ func TestGenerateLink(t *testing.T) {
file: "main.go", file: "main.go",
line: int64(20), line: int64(20),
}, },
want: "https://dev.azure.com/org/project/_git/repo?path=main.go&version=GBabcdef&line=20", want: "https://dev.azure.com/org/project/_git/repo/commit/abcdef/main.go?line=20",
}, },
} }
for _, tt := range tests { for _, tt := range tests {