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

Configure Feed

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

Add URL Template for Gitea (#453)

This adds a URL template for gitea >= 1.17.0.

The "display=source" query parameter was introduced in gitea 1.17.0 and
is required to disable file rendering. Line numbers are disabled in
rendered files, so you wouldn't be able to jump to a line without
"display=source".

The "web-url-type = gitea" config option must be set in the bare
repositories indexed with "zoekt-git-index" e.g. in
owner/repo.git/config:

[zoekt]
web-url-type = gitea
web-url = https://gitea.local/owner/repo
name = owner/repo

Note: already indexed repos must be deleted before reindexing in order
to pick up the indexer changes.

+39 -1
+30 -1
doc/indexing.md
··· 9 9 `https://github.com/hanwen/usb` 10 10 11 11 * `web-url-type`: type of URL, eg. github. Supported are cgit, 12 - gitiles, gitweb and cgit. 12 + gitiles, gitweb, cgit and gitea. 13 13 14 14 * `github-stars`, `github-forks`, `github-watchers`, 15 15 `github-subscribers`: counters for github interactions 16 + 17 + ## Examples 18 + 19 + ### gitea 20 + 21 + Clone a remote repository and add the indexer configuration. 22 + 23 + ```sh 24 + git clone --bare https://codeberg.org/Codeberg/gitea 25 + cd gitea.git 26 + git config zoekt.web-url-type gitea 27 + git config zoekt.web-url https://codeberg.org/Codeberg/gitea 28 + git config zoekt.name codeberg.org/Codeberg/gitea 29 + ``` 30 + 31 + The tail of the git *config* should then contain: 32 + 33 + ```ini 34 + [zoekt] 35 + web-url-type = gitea 36 + web-url = https://codeberg.org/Codeberg/gitea 37 + name = codeberg.org/Codeberg/gitea 38 + ``` 39 + 40 + The *gitea.git* repository can then be indexed with `zoekt-git-index` 41 + 42 + ```sh 43 + zoekt-git-index --branches main -index /data/index -repo_cache /data/repos gitea.git 44 + ```
+9
gitindex/index.go
··· 151 151 repo.CommitURLTemplate = u.String() + "/-/commit/{{.Version}}" 152 152 repo.FileURLTemplate = u.String() + "/-/blob/{{.Version}}/{{.Path}}" 153 153 repo.LineFragmentTemplate = "#L{{.LineNumber}}" 154 + case "gitea": 155 + repo.CommitURLTemplate = u.String() + "/commit/{{.Version}}" 156 + // NOTE The `display=source` query parameter is required to disable file rendering. 157 + // Since line numbers are disabled in rendered files, you wouldn't be able to jump to 158 + // a line without `display=source`. This is supported since gitea 1.17.0. 159 + // When /src/{{.Version}} is used it will redirect to /src/commit/{{.Version}}, 160 + // but the query parameters are obmitted. 161 + repo.FileURLTemplate = u.String() + "/src/commit/{{.Version}}/{{.Path}}?display=source" 162 + repo.LineFragmentTemplate = "#L{{.LineNumber}}" 154 163 default: 155 164 return fmt.Errorf("URL scheme type %q unknown", typ) 156 165 }