fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

feat/gitindex: support more code host URL templates (#1055)

Bitbucket Cloud and Azure DevOps repositories need host-specific URL templates so indexed search results can link back to commits and file locations in their native web UIs. The Azure file template uses the commit-version prefix because Zoekt stores commit SHAs for branch versions, avoiding a branch-only URL form.

Test Plan: go test ./gitindex -run TestSetTemplates

+22
+12
gitindex/index.go
··· 143 143 repo.CommitURLTemplate = urlJoinPath("commits", varVersion) 144 144 repo.FileURLTemplate = urlJoinPath(varPath) + "?at={{.Version}}" 145 145 repo.LineFragmentTemplate = "#{{.LineNumber}}" 146 + case "bitbucket-cloud": 147 + // https://bitbucket.org/<workspace>/<repo_slug>/commits/<version> 148 + // https://bitbucket.org/<workspace>/<repo_slug>/src/<version>/<path> 149 + repo.CommitURLTemplate = urlJoinPath("commits", varVersion) 150 + repo.FileURLTemplate = urlJoinPath("src", varVersion, varPath) 151 + repo.LineFragmentTemplate = "#{{.LineNumber}}" 152 + case "azuredevops": 153 + // https://dev.azure.com/<organization>/<project>/_git/<repo>/commit/<version> 154 + // https://dev.azure.com/<organization>/<project>/_git/<repo>?path=/<path>&version=GC<version> 155 + repo.CommitURLTemplate = urlJoinPath("commit", varVersion) 156 + repo.FileURLTemplate = urlJoinPath() + "?path=/{{.Path}}&version=GC{{.Version}}&_a=contents" 157 + repo.LineFragmentTemplate = "&line={{.LineNumber}}&lineEnd={{.LineNumber}}&lineStartColumn=1&lineEndColumn=200" 146 158 case "gitlab": 147 159 // https://gitlab.com/gitlab-org/omnibus-gitlab/-/commit/b152c864303dae0e55377a1e2c53c9592380ffed 148 160 // https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/aad04155b3f6fc50ede88aedaee7fc624d481149/files/gitlab-config-template/gitlab.rb.template
+10
gitindex/index_test.go
··· 1098 1098 file: "https://example.com/repo/name/dir/name.txt?at=VERSION", 1099 1099 line: "#10", 1100 1100 }, { 1101 + typ: "bitbucket-cloud", 1102 + commit: "https://example.com/repo/name/commits/VERSION", 1103 + file: "https://example.com/repo/name/src/VERSION/dir/name.txt", 1104 + line: "#10", 1105 + }, { 1106 + typ: "azuredevops", 1107 + commit: "https://example.com/repo/name/commit/VERSION", 1108 + file: "https://example.com/repo/name?path=/dir/name.txt&version=GCVERSION&_a=contents", 1109 + line: "&line=10&lineEnd=10&lineStartColumn=1&lineEndColumn=200", 1110 + }, { 1101 1111 typ: "gitlab", 1102 1112 commit: "https://example.com/repo/name/-/commit/VERSION", 1103 1113 file: "https://example.com/repo/name/-/blob/VERSION/dir/name.txt",