diff --git a/gitindex/index.go b/gitindex/index.go index 93c9148e2..3e9f4b6bd 100644 --- a/gitindex/index.go +++ b/gitindex/index.go @@ -143,6 +143,18 @@ func setTemplates(repo *zoekt.Repository, u *url.URL, typ string) error { repo.CommitURLTemplate = urlJoinPath("commits", varVersion) repo.FileURLTemplate = urlJoinPath(varPath) + "?at={{.Version}}" repo.LineFragmentTemplate = "#{{.LineNumber}}" + case "bitbucket-cloud": + // https://bitbucket.org///commits/ + // https://bitbucket.org///src// + repo.CommitURLTemplate = urlJoinPath("commits", varVersion) + repo.FileURLTemplate = urlJoinPath("src", varVersion, varPath) + repo.LineFragmentTemplate = "#{{.LineNumber}}" + case "azuredevops": + // https://dev.azure.com///_git//commit/ + // https://dev.azure.com///_git/?path=/&version=GC + repo.CommitURLTemplate = urlJoinPath("commit", varVersion) + repo.FileURLTemplate = urlJoinPath() + "?path=/{{.Path}}&version=GC{{.Version}}&_a=contents" + repo.LineFragmentTemplate = "&line={{.LineNumber}}&lineEnd={{.LineNumber}}&lineStartColumn=1&lineEndColumn=200" case "gitlab": // https://gitlab.com/gitlab-org/omnibus-gitlab/-/commit/b152c864303dae0e55377a1e2c53c9592380ffed // https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/aad04155b3f6fc50ede88aedaee7fc624d481149/files/gitlab-config-template/gitlab.rb.template diff --git a/gitindex/index_test.go b/gitindex/index_test.go index d8d303751..c62148e6b 100644 --- a/gitindex/index_test.go +++ b/gitindex/index_test.go @@ -1097,6 +1097,16 @@ func TestSetTemplates(t *testing.T) { commit: "https://example.com/repo/name/commits/VERSION", file: "https://example.com/repo/name/dir/name.txt?at=VERSION", line: "#10", + }, { + typ: "bitbucket-cloud", + commit: "https://example.com/repo/name/commits/VERSION", + file: "https://example.com/repo/name/src/VERSION/dir/name.txt", + line: "#10", + }, { + typ: "azuredevops", + commit: "https://example.com/repo/name/commit/VERSION", + file: "https://example.com/repo/name?path=/dir/name.txt&version=GCVERSION&_a=contents", + line: "&line=10&lineEnd=10&lineStartColumn=1&lineEndColumn=200", }, { typ: "gitlab", commit: "https://example.com/repo/name/-/commit/VERSION",