mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-06-22 10:02:15 +00:00
Add code search with zoekt support (#8827)
This PR adds zoekt as a code search engine for forgejo. This Pull Request is a continuation of the discussion #8302. The meilisearch search engine was not suitable, as it is not designed for searching by code. The zoekt project was proposed instead. Zoekt copes well with code indexing, but its operating principle differs from such search engines as elasticsearch. While elasticsearch can return a result in a ready-made form (with pagination, ready-made snippets, etc.) and forgejo only needs to show this result in the interface with a little work with the data, zoekt works completely differently. Zoekt finds matches in the repository index and returns a response. The response contains a line with the search word, its number from the file, and also a context, if specified in the request. This response is not suitable for Forgejo, so you need to assemble it yourself. To assemble the response from Zoekt into a form acceptable for Forgejo, I had to write some code and create a new function `searchZoektResult`, since the existing `searchResult` function is completely unsuitable for this search engine. I also had to write logic for pagination, highlighting, and correct display of lines in found snippets with a match, but this is a feature of Zoekt. At the moment, Zoekt does not support deleting a repository index by repo_id, it only supports complete deletion of all repositories. But I still implemented the Delete function, which deletes a specific repository by its ID. Co-authored-by: Aleksandr Gamzin <gamzin@altlinux.org> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8827 Reviewed-by: Shiny Nematoda <snematoda@noreply.codeberg.org> Reviewed-by: Gusted <gusted@noreply.codeberg.org>
This commit is contained in:
parent
6f5df4fae6
commit
e35880e7ac
19 changed files with 1334 additions and 130 deletions
45
assets/go-licenses.json
generated
45
assets/go-licenses.json
generated
File diff suppressed because one or more lines are too long
|
|
@ -1481,10 +1481,10 @@ LEVEL = Info
|
|||
;; If empty then it defaults to `sources` only, as if you'd like to disable fully please see REPO_INDEXER_ENABLED.
|
||||
;REPO_INDEXER_REPO_TYPES = sources,forks,mirrors,templates
|
||||
;;
|
||||
;; Code search engine type, could be `bleve` or `elasticsearch`.
|
||||
;; Code search engine type, could be `bleve`, `zoekt` or `elasticsearch`.
|
||||
;REPO_INDEXER_TYPE = bleve
|
||||
;;
|
||||
;; Index file used for code search. available when `REPO_INDEXER_TYPE` is bleve
|
||||
;; Index file used for code search. available when `REPO_INDEXER_TYPE` is bleve or zoekt
|
||||
;REPO_INDEXER_PATH = indexers/repos.bleve
|
||||
;;
|
||||
;; Code indexer connection string, available when `REPO_INDEXER_TYPE` is elasticsearch. i.e. http://elastic:changeme@localhost:9200
|
||||
|
|
@ -1494,10 +1494,10 @@ LEVEL = Info
|
|||
;REPO_INDEXER_NAME = gitea_codes
|
||||
;;
|
||||
;; A comma separated list of glob patterns (see https://github.com/gobwas/glob) to include
|
||||
;; in the index; default is empty
|
||||
;; in the index; it's not compatible with the `zoekt` indexer type; default is empty
|
||||
;REPO_INDEXER_INCLUDE =
|
||||
;;
|
||||
;; A comma separated list of glob patterns to exclude from the index; ; default is empty
|
||||
;; A comma separated list of glob patterns to exclude from the index; it's not compatible with the `zoekt` indexer type; default is empty
|
||||
;REPO_INDEXER_EXCLUDE =
|
||||
;;
|
||||
;; If vendored files should be excluded.
|
||||
|
|
|
|||
11
go.mod
11
go.mod
|
|
@ -92,6 +92,7 @@ require (
|
|||
github.com/redis/go-redis/v9 v9.19.0
|
||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
|
||||
github.com/sergi/go-diff v1.4.0
|
||||
github.com/sourcegraph/zoekt v0.0.0-20260114143800-c747a3bccc2a
|
||||
github.com/stretchr/testify v1.11.1
|
||||
github.com/syndtr/goleveldb v1.0.0
|
||||
github.com/ulikunitz/xz v0.5.15
|
||||
|
|
@ -117,10 +118,11 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go/compute/metadata v0.6.0 // indirect
|
||||
cloud.google.com/go/compute/metadata v0.7.0 // indirect
|
||||
code.superseriousbusiness.org/go-png-image-structure/v2 v2.3.0 // indirect
|
||||
filippo.io/edwards25519 v1.2.0 // indirect
|
||||
git.sr.ht/~mariusor/go-xsd-duration v0.0.0-20220703122237-02e73435a078 // indirect
|
||||
github.com/RoaringBitmap/roaring v1.9.4 // indirect
|
||||
github.com/RoaringBitmap/roaring/v2 v2.14.5 // indirect
|
||||
github.com/STARRY-S/zip v0.2.3 // indirect
|
||||
github.com/andybalholm/brotli v1.2.0 // indirect
|
||||
|
|
@ -147,6 +149,7 @@ require (
|
|||
github.com/blevesearch/zapx/v15 v15.4.3 // indirect
|
||||
github.com/blevesearch/zapx/v16 v16.3.4 // indirect
|
||||
github.com/blevesearch/zapx/v17 v17.1.2 // indirect
|
||||
github.com/bmatcuk/doublestar v1.3.4 // indirect
|
||||
github.com/bmatcuk/doublestar/v4 v4.10.0 // indirect
|
||||
github.com/bodgit/plumbing v1.3.0 // indirect
|
||||
github.com/bodgit/sevenzip v1.6.1 // indirect
|
||||
|
|
@ -195,6 +198,8 @@ require (
|
|||
github.com/gorilla/css v1.0.1 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
github.com/grafana/regexp v0.0.0-20240607082908-2cb410fa05da // indirect
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
|
|
@ -226,6 +231,7 @@ require (
|
|||
github.com/olekukonko/tablewriter v1.0.7 // indirect
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
github.com/onsi/gomega v1.34.1 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/philhofer/fwd v1.2.0 // indirect
|
||||
github.com/pierrec/lz4/v4 v4.1.22 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
|
|
@ -239,6 +245,7 @@ require (
|
|||
github.com/rs/xid v1.6.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.4 // indirect
|
||||
github.com/sorairolake/lzip-go v0.3.8 // indirect
|
||||
github.com/sourcegraph/go-ctags v0.0.0-20250729094530-349a251d78d8 // indirect
|
||||
github.com/spf13/afero v1.15.0 // indirect
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
|
|
@ -256,6 +263,8 @@ require (
|
|||
golang.org/x/mod v0.35.0 // indirect
|
||||
golang.org/x/time v0.15.0 // indirect
|
||||
golang.org/x/tools v0.44.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
|
||||
google.golang.org/grpc v1.75.0 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
|
|
|
|||
110
go.sum
110
go.sum
|
|
@ -9,8 +9,8 @@ cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6T
|
|||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4j01OwKxG9I=
|
||||
cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
|
||||
cloud.google.com/go/compute/metadata v0.7.0 h1:PBWF+iiAerVNe8UCHxdOt6eHLVc3ydFeOCw78U8ytSU=
|
||||
cloud.google.com/go/compute/metadata v0.7.0/go.mod h1:j5MvL9PprKL39t166CoB1uVHfQMs4tFQZZcKwksXUjo=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
|
|
@ -69,6 +69,8 @@ github.com/42wim/sshsig v0.0.0-20250502153856-5100632e8920 h1:mWAVGlovzUfREJBhm0
|
|||
github.com/42wim/sshsig v0.0.0-20250502153856-5100632e8920/go.mod h1:zWxcT7BIWOe05xVJL0VMvO/PJ6RpoCux10heb77H6Q8=
|
||||
github.com/6543/go-version v1.3.1 h1:HvOp+Telns7HWJ2Xo/05YXQSB2bE0WmVgbHqwMPZT4U=
|
||||
github.com/6543/go-version v1.3.1/go.mod h1:oqFAHCwtLVUTLdhQmVZWYvaHXTdsbB4SY85at64SQEo=
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU=
|
||||
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8=
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 h1:mFRzDkZVAjdal+s7s0MwaRv9igoPqLRdzOLzw/8Xvq8=
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
|
|
@ -77,6 +79,8 @@ github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67
|
|||
github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo=
|
||||
github.com/PuerkitoBio/goquery v1.12.0 h1:pAcL4g3WRXekcB9AU/y1mbKez2dbY2AajVhtkO8RIBo=
|
||||
github.com/PuerkitoBio/goquery v1.12.0/go.mod h1:802ej+gV2y7bbIhOIoPY5sT183ZW0YFofScC4q/hIpQ=
|
||||
github.com/RoaringBitmap/roaring v1.9.4 h1:yhEIoH4YezLYT04s1nHehNO64EKFTop/wBhxv2QzDdQ=
|
||||
github.com/RoaringBitmap/roaring v1.9.4/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
|
||||
github.com/RoaringBitmap/roaring/v2 v2.14.5 h1:ckd0o545JqDPeVJDgeFoaM21eBixUnlWfYgjE5VnyWw=
|
||||
github.com/RoaringBitmap/roaring/v2 v2.14.5/go.mod h1:eq4wdNXxtJIS/oikeCzdX1rBzek7ANzbth041hrU8Q4=
|
||||
github.com/STARRY-S/zip v0.2.3 h1:luE4dMvRPDOWQdeDdUxUoZkzUIpTccdKdhHHsQJ1fm4=
|
||||
|
|
@ -101,8 +105,10 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
|
|||
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/bits-and-blooms/bitset v1.24.2 h1:M7/NzVbsytmtfHbumG+K2bremQPMJuqv1JD3vOaFxp0=
|
||||
github.com/bits-and-blooms/bitset v1.24.2/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
|
||||
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb h1:m935MPodAbYS46DG4pJSv7WO+VECIWUQ7OJYSoTrMh4=
|
||||
|
|
@ -145,6 +151,8 @@ github.com/blevesearch/zapx/v16 v16.3.4 h1:hDAqA8qusZTNbPEL7//w5P65UZ2de6yhSeUaT
|
|||
github.com/blevesearch/zapx/v16 v16.3.4/go.mod h1:zqkPPqs9GS9FzVWzCO3Wf1X044yWAV17+4zb+FTiEHg=
|
||||
github.com/blevesearch/zapx/v17 v17.1.2 h1:avbOk2igaASNoiy0BE/jPgcxAnRI2PGeydeP4hg7Ikk=
|
||||
github.com/blevesearch/zapx/v17 v17.1.2/go.mod h1:WQObxKrqUX7cd0G1GMvDfc/bmZzQvoy7APOPimx7DiI=
|
||||
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
|
||||
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
|
||||
github.com/bmatcuk/doublestar/v4 v4.10.0 h1:zU9WiOla1YA122oLM6i4EXvGW62DvKZVxIe6TYWexEs=
|
||||
github.com/bmatcuk/doublestar/v4 v4.10.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
|
||||
github.com/bodgit/plumbing v1.3.0 h1:pf9Itz1JOQgn7vEOE7v7nlEfBykYqvUYioC61TwWCFU=
|
||||
|
|
@ -189,6 +197,7 @@ github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJ
|
|||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
|
||||
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
|
|
@ -242,14 +251,18 @@ github.com/emersion/go-sasl v0.0.0-20200509203442-7bfe0ed36a21/go.mod h1:iL2twTe
|
|||
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43 h1:hH4PQfOndHDlpzYfLAAfl63E8Le6F2+EL/cdhlkyRJY=
|
||||
github.com/emersion/go-sasl v0.0.0-20231106173351-e73c9f7bad43/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ=
|
||||
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594/go.mod h1:aqO8z8wPrjkscevZJFVE1wXJrLpC5LtJG7fqLOsPb2U=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w=
|
||||
github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE=
|
||||
github.com/felixge/fgprof v0.9.5 h1:8+vR6yu2vvSKn08urWyEuxx75NWPEvybbkBirEpsbVY=
|
||||
github.com/felixge/fgprof v0.9.5/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
|
||||
|
|
@ -290,8 +303,14 @@ github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
|||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-jose/go-jose/v4 v4.1.3 h1:CVLmWDhDVRa6Mi/IgCgaopNosCaHz7zrMeF9MlZRkrs=
|
||||
github.com/go-jose/go-jose/v4 v4.1.3/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-ldap/ldap/v3 v3.4.12 h1:1b81mv7MagXZ7+1r7cLTWmyuTqVqdwbtJSjC0DAp9s4=
|
||||
github.com/go-ldap/ldap/v3 v3.4.12/go.mod h1:+SPAGcTtOfmGsCb3h1RFiq4xpp4N636G75OEace8lNo=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-openapi/jsonpointer v0.22.4 h1:dZtK82WlNpVLDW2jlA1YCiVJFVqkED1MegOUy9kR5T4=
|
||||
github.com/go-openapi/jsonpointer v0.22.4/go.mod h1:elX9+UgznpFhgBuaMQ7iu4lvvX1nvNsesQ3oxmYTw80=
|
||||
github.com/go-openapi/jsonreference v0.21.4 h1:24qaE2y9bx/q3uRK/qN+TDwbok1NhbSmGjjySRCHtC8=
|
||||
|
|
@ -320,6 +339,7 @@ github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6
|
|||
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
|
||||
github.com/go-sql-driver/mysql v1.10.0 h1:Q+1LV8DkHJvSYAdR83XzuhDaTykuDx0l6fkXxoWCWfw=
|
||||
github.com/go-sql-driver/mysql v1.10.0/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/go-test/deep v1.1.1 h1:0r/53hagsehfO4bzD2Pgr/+RgHqhmf+k1Bpse2cTu1U=
|
||||
github.com/go-test/deep v1.1.1/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
|
|
@ -336,6 +356,7 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA
|
|||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f h1:3BSP1Tbs2djlpprl7wCLuiqMaUh5SJkkzI2gDs+FgLs=
|
||||
github.com/gogs/chardet v0.0.0-20211120154057-b7413eaefb8f/go.mod h1:Pcatq5tYkCW2Q6yrR2VRHlbHpZ/R4/7qyL1TCF7vl14=
|
||||
github.com/gogs/go-gogs-client v0.0.0-20210131175652-1d7215cd8d85 h1:UjoPNDAQ5JPCjlxoJd6K8ALZqSDDhk2ymieAZOVaDg0=
|
||||
|
|
@ -366,6 +387,8 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU
|
|||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
|
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
|
||||
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
|
|
@ -378,7 +401,11 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
|||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
|
||||
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
|
|
@ -420,6 +447,10 @@ github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kX
|
|||
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||
github.com/gorilla/sessions v1.4.0 h1:kpIYOp/oi6MG/p5PgxApU8srsSw9tuFbt46Lt7auzqQ=
|
||||
github.com/gorilla/sessions v1.4.0/go.mod h1:FLWm50oby91+hl7p/wRxDth9bWSuk0qVL2emc7lT5ik=
|
||||
github.com/grafana/regexp v0.0.0-20240607082908-2cb410fa05da h1:BML5sNe+bw2uO8t8cQSwe5QhvoP04eHPF7bnaQma0Kw=
|
||||
github.com/grafana/regexp v0.0.0-20240607082908-2cb410fa05da/go.mod h1:+JKpmjMGhpgPL+rXZ5nsZieVzvarn86asRlBg4uNGnk=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
||||
|
|
@ -432,8 +463,13 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/hexops/autogold v0.8.1/go.mod h1:97HLDXyG23akzAoRYJh/2OBs3kd80eHyKPvZw0S5ZBY=
|
||||
github.com/hexops/autogold v1.3.1 h1:YgxF9OHWbEIUjhDbpnLhgVsjUDsiHDTyDfy2lrfdlzo=
|
||||
github.com/hexops/autogold v1.3.1/go.mod h1:sQO+mQUCVfxOKPht+ipDSkJ2SCJ7BNJVHZexsXqWMx4=
|
||||
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
|
||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
||||
github.com/hexops/valast v1.4.3 h1:oBoGERMJh6UZdRc6cduE1CTPK+VAdXA59Y1HFgu3sm0=
|
||||
github.com/hexops/valast v1.4.3/go.mod h1:Iqx2kLj3Jn47wuXpj3wX40xn6F93QNFBHuiKBerkTGA=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI=
|
||||
github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
|
||||
|
|
@ -473,6 +509,7 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
|
|||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
|
||||
|
|
@ -485,6 +522,7 @@ github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM
|
|||
github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw=
|
||||
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
|
||||
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
|
|
@ -510,8 +548,13 @@ github.com/markbates/going v1.0.3 h1:mY45T5TvW+Xz5A6jY7lf4+NLg9D8+iuStIHyR7M8qsE
|
|||
github.com/markbates/going v1.0.3/go.mod h1:fQiT6v6yQar9UD6bd/D4Z5Afbk9J6BBVBtLiyY4gp2o=
|
||||
github.com/markbates/goth v1.82.0 h1:8j/c34AjBSTNzO7zTsOyP5IYCQCMBTRBHAbBt/PI0bQ=
|
||||
github.com/markbates/goth v1.82.0/go.mod h1:/DRlcq0pyqkKToyZjsL2KgiA1zbF1HIjE7u2uC79rUk=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
||||
github.com/mattn/go-runewidth v0.0.21 h1:jJKAZiQH+2mIinzCJIaIG9Be1+0NR+5sz/lYEEjdM8w=
|
||||
|
|
@ -553,6 +596,8 @@ github.com/msteinert/pam/v2 v2.1.0 h1:er5F9TKV5nGFuTt12ubtqPHEUdeBwReP7vd3wovidG
|
|||
github.com/msteinert/pam/v2 v2.1.0/go.mod h1:KT28NNIcDFf3PcBmNI2mIGO4zZJ+9RSs/At2PB3IDVc=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/nightlyone/lockfile v1.0.0 h1:RHep2cFKK4PonZJDdEl4GmkabuhbsRMgk/k3uAmxBiA=
|
||||
github.com/nightlyone/lockfile v1.0.0/go.mod h1:rywoIealpdNse2r832aiD9jRk8ErCatROs6LzC841CI=
|
||||
github.com/niklasfasching/go-org v1.9.1 h1:/3s4uTPOF06pImGa2Yvlp24yKXZoTYM+nsIlMzfpg/0=
|
||||
github.com/niklasfasching/go-org v1.9.1/go.mod h1:ZAGFFkWvUQcpazmi/8nHqwvARpr1xpb+Es67oUGX/48=
|
||||
github.com/nwaples/rardecode/v2 v2.2.0 h1:4ufPGHiNe1rYJxYfehALLjup4Ls3ck42CWwjKiOqu0A=
|
||||
|
|
@ -582,12 +627,16 @@ github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8
|
|||
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
|
||||
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
|
||||
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
|
||||
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
|
||||
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
||||
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
|
||||
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
|
|
@ -615,6 +664,7 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG
|
|||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
|
||||
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
|
||||
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
||||
|
|
@ -625,19 +675,26 @@ github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCw
|
|||
github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs=
|
||||
github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw=
|
||||
github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
|
||||
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
|
||||
github.com/sorairolake/lzip-go v0.3.8 h1:j5Q2313INdTA80ureWYRhX+1K78mUXfMoPZCw/ivWik=
|
||||
github.com/sorairolake/lzip-go v0.3.8/go.mod h1:JcBqGMV0frlxwrsE9sMWXDjqn3EeVf0/54YPsw66qkU=
|
||||
github.com/sourcegraph/go-ctags v0.0.0-20250729094530-349a251d78d8 h1:hpCD/FvbXLR7/034fKD0CQ8LmT4zoQfT2DzJIjqMzUI=
|
||||
github.com/sourcegraph/go-ctags v0.0.0-20250729094530-349a251d78d8/go.mod h1:Or1cqbhDzkbH+hlwv5iW7uCTPEMKH9u/mTUh7otRQHY=
|
||||
github.com/sourcegraph/zoekt v0.0.0-20260114143800-c747a3bccc2a h1:kgHKGkR9Yv4EhNuzmcmGkq6Zl3CR+VVskh2W77716ls=
|
||||
github.com/sourcegraph/zoekt v0.0.0-20260114143800-c747a3bccc2a/go.mod h1:gaIBJomM/+Rr1BYwXgD3ZoHEM4x1H0ytfCPKUOtRmsk=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf h1:pvbZ0lM0XWPBqUKqFU8cmavspvIl9nulOYwdy6IFRRo=
|
||||
github.com/ssor/bom v0.0.0-20170718123548-6386211fdfcf/go.mod h1:RJID2RhlZKId02nZ62WenDCkgHFerpIOmW0iT7GKmXM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
|
|
@ -665,6 +722,7 @@ github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZ
|
|||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
github.com/yohcop/openid-go v1.0.1 h1:DPRd3iPO5F6O5zX2e62XpVAbPT6wV51cuucH0z9g3js=
|
||||
github.com/yohcop/openid-go v1.0.1/go.mod h1:b/AvD03P0KHj4yuihb+VtLD6bYYgsy0zqBzPCRjkCNs=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/yuin/goldmark v1.4.15/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
|
|
@ -688,15 +746,31 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
|||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
|
||||
go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y=
|
||||
go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I=
|
||||
go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0=
|
||||
go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM=
|
||||
go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg=
|
||||
go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.37.0 h1:90lI228XrB9jCMuSdA0673aubgRobVZFhbjxHHspCPc=
|
||||
go.opentelemetry.io/otel/sdk/metric v1.37.0/go.mod h1:cNen4ZWfiD37l5NhS+Keb5RXVWZWpRE+9WyVCpbo5ps=
|
||||
go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A=
|
||||
go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
|
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
|
||||
go.uber.org/zap v1.27.1 h1:08RqriUEv8+ArZRYSTXy1LeBScaMpVSTBhCeaZYfMYc=
|
||||
go.uber.org/zap v1.27.1/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
|
||||
go.uber.org/zap/exp v0.3.0 h1:6JYzdifzYkGmTdRR59oYH+Ng7k49H9qVpWwNSsGJj3U=
|
||||
|
|
@ -751,6 +825,7 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB
|
|||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
|
|
@ -771,6 +846,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200320220750-118fecf932d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
|
|
@ -780,6 +856,7 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
|
|
@ -804,6 +881,7 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ
|
|||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
|
|
@ -816,6 +894,7 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h
|
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
|
@ -826,18 +905,25 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
|
@ -850,6 +936,7 @@ golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
|||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
|
|
@ -865,6 +952,7 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
|||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
|
|
@ -892,6 +980,7 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
|
|||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
|
|
@ -901,8 +990,11 @@ golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapK
|
|||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
|
|
@ -912,6 +1004,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
|
|||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
|
||||
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
|
|
@ -938,13 +1032,20 @@ google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvx
|
|||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 h1:eaY8u2EuxbRv7c3NiGK0/NedzVsCcV6hDuU5qPX5EGE=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5/go.mod h1:M4/wBTSeyLxupu3W3tJtOgB14jILAS/XWPSSa3TAlJc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.75.0 h1:+TW+dqTd2Biwe6KKfhE5JpiYIBWq865PhKGSXiivqt4=
|
||||
google.golang.org/grpc v1.75.0/go.mod h1:JtPAzKiq4v1xcAB2hydNlWI2RnF85XXcV0mhKXr2ecQ=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
|
|
@ -977,6 +1078,7 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
|
||||
|
|
@ -986,8 +1088,12 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
mvdan.cc/gofumpt v0.4.0 h1:JVf4NN1mIpHogBj7ABpgOyZc65/UUOkKQFkoURsz4MM=
|
||||
mvdan.cc/gofumpt v0.4.0/go.mod h1:PljLOHDeZqgS8opHRKLzp2It2VBuSdteAgqUfzMTxlQ=
|
||||
mvdan.cc/xurls/v2 v2.6.0 h1:3NTZpeTxYVWNSokW3MKeyVkz/j7uYXYiMtXRUfmjbgI=
|
||||
mvdan.cc/xurls/v2 v2.6.0/go.mod h1:bCvEZ1XvdA6wDnxY7jPPjEmigDtvtvPXAD/Exa9IMSk=
|
||||
pgregory.net/rapid v1.2.0 h1:keKAYRcjm+e1F0oAuU5F5+YPAWcyxNNRK2wud503Gnk=
|
||||
pgregory.net/rapid v1.2.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
|
|
|
|||
|
|
@ -384,3 +384,7 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
|
|||
}
|
||||
return total, searchResults, searchResultLanguages, nil
|
||||
}
|
||||
|
||||
func (b *Indexer) Formatter() internal.ResultFormatter {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -418,3 +418,7 @@ func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int
|
|||
|
||||
return total, hits, extractAggs(countResult), err
|
||||
}
|
||||
|
||||
func (b *Indexer) Formatter() internal.ResultFormatter {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
10
modules/indexer/code/highlight.go
Normal file
10
modules/indexer/code/highlight.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package code
|
||||
|
||||
import "forgejo.org/modules/indexer/code/internal"
|
||||
|
||||
func HighlightSearchResultCode(filename string, lineNums []int, highlightRanges [][3]int, code string) []internal.ResultLine {
|
||||
return internal.HighlightSearchResultCode(filename, lineNums, highlightRanges, code)
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ import (
|
|||
"forgejo.org/modules/indexer/code/bleve"
|
||||
"forgejo.org/modules/indexer/code/elasticsearch"
|
||||
"forgejo.org/modules/indexer/code/internal"
|
||||
"forgejo.org/modules/indexer/code/zoekt"
|
||||
"forgejo.org/modules/log"
|
||||
"forgejo.org/modules/process"
|
||||
"forgejo.org/modules/queue"
|
||||
|
|
@ -129,7 +130,7 @@ func Init() {
|
|||
|
||||
// Create the Queue
|
||||
switch setting.Indexer.RepoType {
|
||||
case "bleve", "elasticsearch":
|
||||
case "bleve", "elasticsearch", "zoekt":
|
||||
handler := func(items ...*internal.IndexerData) (unhandled []*internal.IndexerData) {
|
||||
indexer := *globalIndexer.Load()
|
||||
// make it a process to allow for cancellation (especially during integration tests where no global shutdown happens)
|
||||
|
|
@ -200,6 +201,25 @@ func Init() {
|
|||
close(waitChannel)
|
||||
log.Fatal("PID: %d Unable to initialize the elasticsearch Repository Indexer connstr: %s Error: %v", os.Getpid(), util.SanitizeCredentialURLs(setting.Indexer.RepoConnStr), err)
|
||||
}
|
||||
case "zoekt":
|
||||
log.Info("PID: %d Initializing Repository Indexer at: %s", os.Getpid(), setting.Indexer.RepoPath)
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Error("PANIC whilst initializing repository indexer: %v\nStacktrace: %s", err, log.Stack(2))
|
||||
log.Error("The indexer files are likely corrupted and may need to be deleted")
|
||||
log.Error("You can completely remove the \"%s\" directory to make Gitea recreate the indexes", setting.Indexer.RepoPath)
|
||||
}
|
||||
}()
|
||||
|
||||
rIndexer = zoekt.NewIndexer(setting.Indexer.RepoPath)
|
||||
existed, err = rIndexer.Init(ctx)
|
||||
if err != nil {
|
||||
cancel()
|
||||
(*globalIndexer.Load()).Close()
|
||||
close(waitChannel)
|
||||
|
||||
log.Fatal("PID: %d Unable to initialize the zoekt Repository Indexer at path: %s Error: %v", os.Getpid(), setting.Indexer.RepoPath, err)
|
||||
}
|
||||
|
||||
default:
|
||||
log.Fatal("PID: %d Unknown Indexer type: %s", os.Getpid(), setting.Indexer.RepoType)
|
||||
|
|
|
|||
114
modules/indexer/code/internal/highlight.go
Normal file
114
modules/indexer/code/internal/highlight.go
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
"strings"
|
||||
|
||||
"forgejo.org/modules/highlight"
|
||||
"forgejo.org/services/gitdiff"
|
||||
)
|
||||
|
||||
func WriteStrings(buf *bytes.Buffer, strs ...string) error {
|
||||
for _, s := range strs {
|
||||
_, err := buf.WriteString(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
highlightTagStart = "<span class=\"search-highlight\">"
|
||||
highlightTagEnd = "</span>"
|
||||
)
|
||||
|
||||
func HighlightSearchResultCode(filename string, lineNums []int, highlightRanges [][3]int, code string) []ResultLine {
|
||||
hcd := gitdiff.NewHighlightCodeDiff()
|
||||
hcd.CollectUsedRunes(code)
|
||||
startTag, endTag := hcd.NextPlaceholder(), hcd.NextPlaceholder()
|
||||
hcd.PlaceholderTokenMap[startTag] = highlightTagStart
|
||||
hcd.PlaceholderTokenMap[endTag] = highlightTagEnd
|
||||
|
||||
// we should highlight the whole code block first, otherwise it doesn't work well with multiple line highlighting
|
||||
hl, _ := highlight.Code(filename, "", code)
|
||||
conv := hcd.ConvertToPlaceholders(string(hl))
|
||||
convLines := strings.Split(conv, "\n")
|
||||
|
||||
// each highlightRange is of the form [line number, start byte offset, end byte offset]
|
||||
for _, highlightRange := range highlightRanges {
|
||||
ln, start, end := highlightRange[0], highlightRange[1], highlightRange[2]
|
||||
line := convLines[ln]
|
||||
if line == "" || len(line) <= start || len(line) < end {
|
||||
continue
|
||||
}
|
||||
|
||||
sr := strings.NewReader(line)
|
||||
sb := strings.Builder{}
|
||||
count := -1
|
||||
isOpen := false
|
||||
for r, size, err := sr.ReadRune(); err == nil; r, size, err = sr.ReadRune() {
|
||||
if token, ok := hcd.PlaceholderTokenMap[r];
|
||||
// token was not found
|
||||
!ok {
|
||||
count += size
|
||||
} else if
|
||||
// token was marked as used
|
||||
token == "" ||
|
||||
// the token is not an valid html tag emitted by chroma
|
||||
!(len(token) > 6 && (token[0:5] == "<span" || token[0:6] == "</span")) {
|
||||
count++
|
||||
} else if !isOpen {
|
||||
// open the tag only after all other placeholders
|
||||
sb.WriteRune(r)
|
||||
continue
|
||||
} else if isOpen && count < end {
|
||||
// if the tag is open, but a placeholder exists in between
|
||||
// close the tag
|
||||
sb.WriteRune(endTag)
|
||||
// write the placeholder
|
||||
sb.WriteRune(r)
|
||||
// reopen the tag
|
||||
sb.WriteRune(startTag)
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case count >= end:
|
||||
// if tag is not open, no need to close
|
||||
if !isOpen {
|
||||
break
|
||||
}
|
||||
sb.WriteRune(endTag)
|
||||
isOpen = false
|
||||
case count >= start:
|
||||
// if tag is open, do not open again
|
||||
if isOpen {
|
||||
break
|
||||
}
|
||||
isOpen = true
|
||||
sb.WriteRune(startTag)
|
||||
}
|
||||
|
||||
sb.WriteRune(r)
|
||||
}
|
||||
if isOpen {
|
||||
sb.WriteRune(endTag)
|
||||
}
|
||||
convLines[ln] = sb.String()
|
||||
}
|
||||
conv = strings.Join(convLines, "\n")
|
||||
|
||||
highlightedLines := strings.Split(hcd.Recover(conv), "\n")
|
||||
// The lineNums outputted by highlight.Code might not match the original lineNums, because "highlight" removes the last `\n`
|
||||
lines := make([]ResultLine, min(len(highlightedLines), len(lineNums)))
|
||||
for i := range len(lines) {
|
||||
lines[i].Num = lineNums[i]
|
||||
lines[i].FormattedContent = template.HTML(highlightedLines[i])
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ type Indexer interface {
|
|||
Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *RepoChanges) error
|
||||
Delete(ctx context.Context, repoID int64) error
|
||||
Search(ctx context.Context, opts *SearchOptions) (int64, []*SearchResult, []*SearchResultLanguages, error)
|
||||
Formatter() ResultFormatter
|
||||
}
|
||||
|
||||
type CodeSearchMode int
|
||||
|
|
@ -72,3 +73,7 @@ func (d *dummyIndexer) Delete(ctx context.Context, repoID int64) error {
|
|||
func (d *dummyIndexer) Search(ctx context.Context, opts *SearchOptions) (int64, []*SearchResult, []*SearchResultLanguages, error) {
|
||||
return 0, nil, nil, errors.New("indexer is not ready")
|
||||
}
|
||||
|
||||
func (d *dummyIndexer) Formatter() ResultFormatter {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,11 @@
|
|||
|
||||
package internal
|
||||
|
||||
import "forgejo.org/modules/timeutil"
|
||||
import (
|
||||
"html/template"
|
||||
|
||||
"forgejo.org/modules/timeutil"
|
||||
)
|
||||
|
||||
type FileUpdate struct {
|
||||
Filename string
|
||||
|
|
@ -23,6 +27,13 @@ type IndexerData struct {
|
|||
RepoID int64
|
||||
}
|
||||
|
||||
// Matches found in code with zoekt indexer
|
||||
type Match struct {
|
||||
Start int
|
||||
End int
|
||||
LineNumber int
|
||||
}
|
||||
|
||||
// SearchResult result of performing a search in a repo
|
||||
type SearchResult struct {
|
||||
RepoID int64
|
||||
|
|
@ -34,6 +45,9 @@ type SearchResult struct {
|
|||
UpdatedUnix timeutil.TimeStamp
|
||||
Language string
|
||||
Color string
|
||||
Matches []Match
|
||||
LineNumbers []int
|
||||
LineOffsets []int
|
||||
}
|
||||
|
||||
// SearchResultLanguages result of top languages count in search results
|
||||
|
|
@ -42,3 +56,22 @@ type SearchResultLanguages struct {
|
|||
Color string
|
||||
Count int
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
RepoID int64
|
||||
Filename string
|
||||
CommitID string
|
||||
UpdatedUnix timeutil.TimeStamp
|
||||
Language string
|
||||
Color string
|
||||
Lines []ResultLine
|
||||
}
|
||||
|
||||
type ResultLine struct {
|
||||
Num int
|
||||
FormattedContent template.HTML
|
||||
}
|
||||
|
||||
type ResultFormatter interface {
|
||||
Format(*SearchResult) (*Result, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,31 +6,15 @@ package code
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"html/template"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"forgejo.org/modules/highlight"
|
||||
"forgejo.org/modules/indexer/code/internal"
|
||||
"forgejo.org/modules/timeutil"
|
||||
"forgejo.org/services/gitdiff"
|
||||
)
|
||||
|
||||
// Result a search result to display
|
||||
type Result struct {
|
||||
RepoID int64
|
||||
Filename string
|
||||
CommitID string
|
||||
UpdatedUnix timeutil.TimeStamp
|
||||
Language string
|
||||
Color string
|
||||
Lines []ResultLine
|
||||
}
|
||||
type Result = internal.Result
|
||||
|
||||
type ResultLine struct {
|
||||
Num int
|
||||
FormattedContent template.HTML
|
||||
}
|
||||
type ResultLine = internal.ResultLine
|
||||
|
||||
type SearchResultLanguages = internal.SearchResultLanguages
|
||||
|
||||
|
|
@ -86,108 +70,15 @@ func indices(content string, selectionStartIndex, selectionEndIndex int) (int, i
|
|||
return startIndex, endIndex
|
||||
}
|
||||
|
||||
func writeStrings(buf *bytes.Buffer, strs ...string) error {
|
||||
for _, s := range strs {
|
||||
_, err := buf.WriteString(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
highlightTagStart = "<span class=\"search-highlight\">"
|
||||
highlightTagEnd = "</span>"
|
||||
)
|
||||
|
||||
func HighlightSearchResultCode(filename string, lineNums []int, highlightRanges [][3]int, code string) []ResultLine {
|
||||
hcd := gitdiff.NewHighlightCodeDiff()
|
||||
hcd.CollectUsedRunes(code)
|
||||
startTag, endTag := hcd.NextPlaceholder(), hcd.NextPlaceholder()
|
||||
hcd.PlaceholderTokenMap[startTag] = highlightTagStart
|
||||
hcd.PlaceholderTokenMap[endTag] = highlightTagEnd
|
||||
|
||||
// we should highlight the whole code block first, otherwise it doesn't work well with multiple line highlighting
|
||||
hl, _ := highlight.Code(filename, "", code)
|
||||
conv := hcd.ConvertToPlaceholders(string(hl))
|
||||
convLines := strings.Split(conv, "\n")
|
||||
|
||||
// each highlightRange is of the form [line number, start byte offset, end byte offset]
|
||||
for _, highlightRange := range highlightRanges {
|
||||
ln, start, end := highlightRange[0], highlightRange[1], highlightRange[2]
|
||||
line := convLines[ln]
|
||||
if line == "" || len(line) <= start || len(line) < end {
|
||||
continue
|
||||
}
|
||||
|
||||
sr := strings.NewReader(line)
|
||||
sb := strings.Builder{}
|
||||
count := -1
|
||||
isOpen := false
|
||||
for r, size, err := sr.ReadRune(); err == nil; r, size, err = sr.ReadRune() {
|
||||
if token, ok := hcd.PlaceholderTokenMap[r];
|
||||
// token was not found
|
||||
!ok {
|
||||
count += size
|
||||
} else if
|
||||
// token was marked as used
|
||||
token == "" ||
|
||||
// the token is not an valid html tag emitted by chroma
|
||||
!(len(token) > 6 && (token[0:5] == "<span" || token[0:6] == "</span")) {
|
||||
count++
|
||||
} else if !isOpen {
|
||||
// open the tag only after all other placeholders
|
||||
sb.WriteRune(r)
|
||||
continue
|
||||
} else if isOpen && count < end {
|
||||
// if the tag is open, but a placeholder exists in between
|
||||
// close the tag
|
||||
sb.WriteRune(endTag)
|
||||
// write the placeholder
|
||||
sb.WriteRune(r)
|
||||
// reopen the tag
|
||||
sb.WriteRune(startTag)
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case count >= end:
|
||||
// if tag is not open, no need to close
|
||||
if !isOpen {
|
||||
break
|
||||
}
|
||||
sb.WriteRune(endTag)
|
||||
isOpen = false
|
||||
case count >= start:
|
||||
// if tag is open, do not open again
|
||||
if isOpen {
|
||||
break
|
||||
}
|
||||
isOpen = true
|
||||
sb.WriteRune(startTag)
|
||||
}
|
||||
|
||||
sb.WriteRune(r)
|
||||
}
|
||||
if isOpen {
|
||||
sb.WriteRune(endTag)
|
||||
}
|
||||
convLines[ln] = sb.String()
|
||||
}
|
||||
conv = strings.Join(convLines, "\n")
|
||||
|
||||
highlightedLines := strings.Split(hcd.Recover(conv), "\n")
|
||||
// The lineNums outputted by highlight.Code might not match the original lineNums, because "highlight" removes the last `\n`
|
||||
lines := make([]ResultLine, min(len(highlightedLines), len(lineNums)))
|
||||
for i := range len(lines) {
|
||||
lines[i].Num = lineNums[i]
|
||||
lines[i].FormattedContent = template.HTML(highlightedLines[i])
|
||||
}
|
||||
return lines
|
||||
}
|
||||
|
||||
func searchResult(result *internal.SearchResult, startIndex, endIndex int) (*Result, error) {
|
||||
formatter := (*globalIndexer.Load()).Formatter()
|
||||
if formatter != nil {
|
||||
return formatter.Format(result)
|
||||
}
|
||||
return searchResultCommon(result, startIndex, endIndex)
|
||||
}
|
||||
|
||||
func searchResultCommon(result *internal.SearchResult, startIndex, endIndex int) (*Result, error) {
|
||||
startLineNum := 1 + strings.Count(result.Content[:startIndex], "\n")
|
||||
|
||||
var formattedLinesBuffer bytes.Buffer
|
||||
|
|
@ -204,13 +95,13 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int) (*Res
|
|||
openActiveIndex := max(result.StartIndex-index, 0)
|
||||
closeActiveIndex := min(result.EndIndex-index, len(line))
|
||||
highlightRanges = append(highlightRanges, [3]int{i, openActiveIndex, closeActiveIndex})
|
||||
err = writeStrings(&formattedLinesBuffer,
|
||||
err = internal.WriteStrings(&formattedLinesBuffer,
|
||||
line[:openActiveIndex],
|
||||
line[openActiveIndex:closeActiveIndex],
|
||||
line[closeActiveIndex:],
|
||||
)
|
||||
} else {
|
||||
err = writeStrings(&formattedLinesBuffer, line)
|
||||
err = internal.WriteStrings(&formattedLinesBuffer, line)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -227,7 +118,7 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int) (*Res
|
|||
UpdatedUnix: result.UpdatedUnix,
|
||||
Language: result.Language,
|
||||
Color: result.Color,
|
||||
Lines: HighlightSearchResultCode(result.Filename, lineNums, highlightRanges, formattedLinesBuffer.String()),
|
||||
Lines: internal.HighlightSearchResultCode(result.Filename, lineNums, highlightRanges, formattedLinesBuffer.String()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
573
modules/indexer/code/zoekt/zoekt.go
Normal file
573
modules/indexer/code/zoekt/zoekt.go
Normal file
|
|
@ -0,0 +1,573 @@
|
|||
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build unix
|
||||
|
||||
package zoekt
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"cmp"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"regexp/syntax"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
repo_model "forgejo.org/models/repo"
|
||||
"forgejo.org/modules/analyze"
|
||||
"forgejo.org/modules/charset"
|
||||
"forgejo.org/modules/git"
|
||||
"forgejo.org/modules/gitrepo"
|
||||
"forgejo.org/modules/indexer/code/internal"
|
||||
indexer_internal "forgejo.org/modules/indexer/internal"
|
||||
inner_zoekt "forgejo.org/modules/indexer/internal/zoekt"
|
||||
"forgejo.org/modules/setting"
|
||||
"forgejo.org/modules/typesniffer"
|
||||
|
||||
"github.com/go-enry/go-enry/v2"
|
||||
"github.com/sourcegraph/zoekt"
|
||||
"github.com/sourcegraph/zoekt/index"
|
||||
"github.com/sourcegraph/zoekt/query"
|
||||
)
|
||||
|
||||
var errSkipIndexing = errors.New("skip indexing")
|
||||
|
||||
const repoIndexerLatestVersion = 1
|
||||
|
||||
type zoektFormatter struct{}
|
||||
|
||||
type Indexer struct {
|
||||
indexer_internal.Indexer // do not composite inner_zoekt.Indexer directly to avoid exposing too much
|
||||
inner *inner_zoekt.Indexer
|
||||
indexDir string
|
||||
}
|
||||
|
||||
func NewIndexer(indexDir string) *Indexer {
|
||||
idxer := inner_zoekt.NewIndexer(indexDir, repoIndexerLatestVersion)
|
||||
return &Indexer{
|
||||
Indexer: idxer,
|
||||
inner: idxer,
|
||||
indexDir: indexDir,
|
||||
}
|
||||
}
|
||||
|
||||
func newZoektIndexBuilder(indexDir string, repo *repo_model.Repository, targetSHA string) (*index.Builder, error) {
|
||||
opts := index.Options{
|
||||
IndexDir: indexDir,
|
||||
SizeMax: int(setting.Indexer.MaxIndexerFileSize),
|
||||
ShardMax: 512 * 1024 * 1024, // 512 MB max shard
|
||||
IsDelta: true,
|
||||
RepositoryDescription: zoekt.Repository{
|
||||
ID: uint32(repo.ID),
|
||||
Name: strconv.FormatInt(repo.ID, 10),
|
||||
Branches: []zoekt.RepositoryBranch{
|
||||
{
|
||||
Name: "HEAD",
|
||||
Version: targetSHA,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if opts.IncrementalSkipIndexing() {
|
||||
return nil, errSkipIndexing
|
||||
}
|
||||
|
||||
opts.SetDefaults()
|
||||
|
||||
builder, err := index.NewBuilder(opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("index.newZoektIndexBuilder: %w", err)
|
||||
}
|
||||
|
||||
return builder, nil
|
||||
}
|
||||
|
||||
func (b *Indexer) addDelete(builder *index.Builder, filename string) {
|
||||
builder.MarkFileAsChangedOrRemoved(filename)
|
||||
}
|
||||
|
||||
func (b *Indexer) addUpdate(ctx context.Context, builder *index.Builder, batchWriter git.WriteCloserError, batchReader *bufio.Reader, update internal.FileUpdate, repo *repo_model.Repository) error {
|
||||
// Ignore vendored files in code search
|
||||
if setting.Indexer.ExcludeVendored && analyze.IsVendor(update.Filename) {
|
||||
return nil
|
||||
}
|
||||
|
||||
size := update.Size
|
||||
var err error
|
||||
if !update.Sized {
|
||||
var stdout string
|
||||
stdout, _, err = git.NewCommand(ctx, "cat-file", "-s").AddDynamicArguments(update.BlobSha).RunStdString(&git.RunOpts{Dir: repo.RepoPath()})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if size, err = strconv.ParseInt(strings.TrimSpace(stdout), 10, 64); err != nil {
|
||||
return fmt.Errorf("misformatted git cat-file output: %w", err)
|
||||
}
|
||||
}
|
||||
if size > setting.Indexer.MaxIndexerFileSize {
|
||||
b.addDelete(builder, update.Filename)
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err := batchWriter.Write([]byte(update.BlobSha + "\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, _, size, err = git.ReadBatchLine(batchReader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fileContents, err := io.ReadAll(io.LimitReader(batchReader, size))
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !typesniffer.DetectContentType(fileContents, update.Filename).IsText() {
|
||||
// FIXME: UTF-16 files will probably fail here
|
||||
return nil
|
||||
}
|
||||
|
||||
if _, err = batchReader.Discard(1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
builder.MarkFileAsChangedOrRemoved(update.Filename)
|
||||
|
||||
branches := []string{"HEAD"}
|
||||
|
||||
err = builder.Add(
|
||||
index.Document{
|
||||
Name: update.Filename,
|
||||
Content: charset.ToUTF8DropErrors(fileContents, charset.ConvertOpts{}),
|
||||
Branches: branches,
|
||||
Language: detectLanguage(update.Filename, fileContents),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error adding document with name %s: %w", update.Filename, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func detectLanguage(filename string, content []byte) string {
|
||||
lang := enry.GetLanguage(filename, content)
|
||||
return normalizeLanguage(lang)
|
||||
}
|
||||
|
||||
// Index will save the index data
|
||||
func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *internal.RepoChanges) error {
|
||||
builder, err := newZoektIndexBuilder(b.indexDir, repo, sha)
|
||||
if errors.Is(err, errSkipIndexing) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("error creating builder: %w", err)
|
||||
}
|
||||
|
||||
if len(changes.Updates) > 0 {
|
||||
r, err := gitrepo.OpenRepository(ctx, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Close()
|
||||
batch, err := r.NewBatch(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer batch.Close()
|
||||
for _, update := range changes.Updates {
|
||||
err := b.addUpdate(ctx, builder, batch.Writer, batch.Reader, update, repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, filename := range changes.RemovedFilenames {
|
||||
b.addDelete(builder, filename)
|
||||
}
|
||||
|
||||
return builder.Finish()
|
||||
}
|
||||
|
||||
func (b *Indexer) Delete(ctx context.Context, repoID int64) error {
|
||||
prefix := strconv.FormatInt(repoID, 10) + "_v"
|
||||
|
||||
dir, err := os.Open(b.indexDir)
|
||||
if err != nil {
|
||||
return fmt.Errorf("open index dir: %w", err)
|
||||
}
|
||||
defer dir.Close()
|
||||
|
||||
names, err := dir.Readdirnames(-1)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read dir: %w", err)
|
||||
}
|
||||
|
||||
prefixLen := len(prefix)
|
||||
|
||||
for _, name := range names {
|
||||
if len(name) < prefixLen {
|
||||
continue
|
||||
}
|
||||
if !strings.HasPrefix(name, prefix) {
|
||||
continue
|
||||
}
|
||||
if strings.HasSuffix(name, ".tmp") || strings.Contains(name, ".zoekt") {
|
||||
_ = os.Remove(filepath.Join(b.indexDir, name))
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func TransToZoektContentQueryString(s string) string {
|
||||
return fmt.Sprintf("content:\"%s\"", s)
|
||||
}
|
||||
|
||||
// generateZoektQuery creates a Zoekt query object based on search options
|
||||
func (b *Indexer) generateZoektQuery(opts *internal.SearchOptions) (query.Q, error) {
|
||||
keyword := opts.Keyword
|
||||
var contentQuery query.Q
|
||||
var err error
|
||||
|
||||
// Zoekt does not support true fuzzy search.
|
||||
// CodeSearchModeFuzzy is therefore treated as a union (OR) search
|
||||
// to preserve previous behavior.
|
||||
switch opts.Mode {
|
||||
case internal.CodeSearchModeUnion, internal.CodeSearchModeFuzzy:
|
||||
fields := strings.Fields(keyword)
|
||||
if len(fields) == 0 {
|
||||
return nil, errors.New("empty keyword")
|
||||
}
|
||||
contentQuery, err = query.Parse(
|
||||
TransToZoektContentQueryString(regexp.QuoteMeta(fields[0])),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, f := range fields[1:] {
|
||||
q, err := query.Parse(
|
||||
TransToZoektContentQueryString(regexp.QuoteMeta(f)),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
contentQuery = query.NewOr(contentQuery, q)
|
||||
}
|
||||
default:
|
||||
// Exact match
|
||||
contentQuery, err = query.Parse(
|
||||
TransToZoektContentQueryString(regexp.QuoteMeta(keyword)),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
finalQuery := contentQuery
|
||||
|
||||
if len(opts.RepoIDs) > 0 {
|
||||
repoIDs := make([]uint32, len(opts.RepoIDs))
|
||||
for i, id := range opts.RepoIDs {
|
||||
repoIDs[i] = uint32(id)
|
||||
}
|
||||
finalQuery = query.NewAnd(finalQuery, query.NewRepoIDs(repoIDs...))
|
||||
}
|
||||
|
||||
if opts.Filename != "" {
|
||||
prefix := strings.TrimPrefix(opts.Filename, "/")
|
||||
|
||||
re, err := syntax.Parse(
|
||||
"^"+regexp.QuoteMeta(prefix),
|
||||
syntax.Perl,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fileQuery := &query.Regexp{
|
||||
Regexp: re,
|
||||
FileName: true,
|
||||
Content: false,
|
||||
}
|
||||
|
||||
finalQuery = query.NewAnd(finalQuery, fileQuery)
|
||||
}
|
||||
|
||||
if opts.Language != "" {
|
||||
lang := opts.Language
|
||||
if lang == "Plain Text" {
|
||||
lang = ""
|
||||
}
|
||||
finalQuery = query.NewAnd(finalQuery, &query.Language{Language: lang})
|
||||
}
|
||||
|
||||
return finalQuery, nil
|
||||
}
|
||||
|
||||
// paginateResults returns a slice of results starting from `skip` index up to `take` number of items.
|
||||
func paginateResults[T any](results []T, skip, take int) []T {
|
||||
if skip >= len(results) {
|
||||
return nil
|
||||
}
|
||||
end := min(skip+take, len(results))
|
||||
return results[skip:end]
|
||||
}
|
||||
|
||||
func getSearchResultLanguages(searchResult *zoekt.SearchResult) []*internal.SearchResultLanguages {
|
||||
languages := make(map[string]int)
|
||||
|
||||
for _, file := range searchResult.Files {
|
||||
lang := normalizeLanguage(file.Language)
|
||||
languages[lang]++
|
||||
}
|
||||
|
||||
searchResultLanguages := make([]*internal.SearchResultLanguages, 0, len(languages))
|
||||
|
||||
for lang, count := range languages {
|
||||
searchResultLanguages = append(searchResultLanguages, &internal.SearchResultLanguages{
|
||||
Language: lang,
|
||||
Count: count,
|
||||
Color: enry.GetColor(lang),
|
||||
})
|
||||
}
|
||||
|
||||
slices.SortFunc(searchResultLanguages, func(a, b *internal.SearchResultLanguages) int {
|
||||
if a.Count != b.Count {
|
||||
return cmp.Compare(b.Count, a.Count)
|
||||
}
|
||||
return cmp.Compare(a.Language, b.Language)
|
||||
})
|
||||
|
||||
return searchResultLanguages
|
||||
}
|
||||
|
||||
func convertZoektResult(files []zoekt.FileMatch) []*internal.SearchResult {
|
||||
results := make([]*internal.SearchResult, 0, len(files))
|
||||
|
||||
for _, f := range files {
|
||||
content := string(f.Content)
|
||||
lines := strings.Split(content, "\n")
|
||||
|
||||
var (
|
||||
contentLines []string
|
||||
lineNumbers []int
|
||||
lineOffsets []int
|
||||
matches []internal.Match
|
||||
)
|
||||
|
||||
offset := 0
|
||||
|
||||
for lineIdx, line := range lines {
|
||||
lineNum := lineIdx + 1
|
||||
|
||||
contentLines = append(contentLines, line)
|
||||
lineNumbers = append(lineNumbers, lineNum)
|
||||
lineOffsets = append(lineOffsets, offset)
|
||||
|
||||
for _, lm := range f.LineMatches {
|
||||
if lm.LineNumber != lineNum {
|
||||
continue
|
||||
}
|
||||
for _, frag := range lm.LineFragments {
|
||||
start := int(frag.Offset)
|
||||
end := start + frag.MatchLength
|
||||
|
||||
matches = append(matches, internal.Match{
|
||||
Start: start,
|
||||
End: end,
|
||||
LineNumber: lineNum,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
offset += len(line) + 1
|
||||
}
|
||||
|
||||
if len(matches) == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
lang := normalizeLanguage(f.Language)
|
||||
|
||||
results = append(results, &internal.SearchResult{
|
||||
RepoID: int64(f.RepositoryID),
|
||||
Filename: f.FileName,
|
||||
CommitID: f.Version,
|
||||
Content: strings.Join(contentLines, "\n"),
|
||||
Language: lang,
|
||||
Color: enry.GetColor(lang),
|
||||
Matches: matches,
|
||||
LineNumbers: lineNumbers,
|
||||
LineOffsets: lineOffsets,
|
||||
})
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
func normalizeLanguage(lang string) string {
|
||||
if lang == "" {
|
||||
return "Plain Text"
|
||||
}
|
||||
return lang
|
||||
}
|
||||
|
||||
func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int64, []*internal.SearchResult, []*internal.SearchResultLanguages, error) {
|
||||
q, err := b.generateZoektQuery(opts)
|
||||
if err != nil {
|
||||
return 0, nil, nil, err
|
||||
}
|
||||
|
||||
result, err := b.inner.Searcher.Search(ctx, q, &zoekt.SearchOptions{
|
||||
Whole: true,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, nil, nil, err
|
||||
}
|
||||
|
||||
allHits := convertZoektResult(result.Files)
|
||||
|
||||
searchResultsLanguages := getSearchResultLanguages(result)
|
||||
|
||||
skip, take := opts.GetSkipTake()
|
||||
pagedHits := paginateResults(allHits, skip, take)
|
||||
|
||||
total := int64(len(allHits))
|
||||
|
||||
return total, pagedHits, searchResultsLanguages, nil
|
||||
}
|
||||
|
||||
func (b *Indexer) Formatter() internal.ResultFormatter {
|
||||
return &zoektFormatter{}
|
||||
}
|
||||
|
||||
func (f *zoektFormatter) Format(r *internal.SearchResult) (*internal.Result, error) {
|
||||
// Sort matches by start position
|
||||
slices.SortFunc(r.Matches, func(a, b internal.Match) int { return a.Start - b.Start })
|
||||
|
||||
// Precompute line offsets once to avoid repeated string slicing
|
||||
lineOffsets := []int{0} // starting index of the first line
|
||||
for i, c := range r.Content {
|
||||
if c == '\n' {
|
||||
lineOffsets = append(lineOffsets, i+1)
|
||||
}
|
||||
}
|
||||
lineOffsets = append(lineOffsets, len(r.Content)) // end offset for the last line
|
||||
|
||||
// Line numbers (1-based)
|
||||
lineNumbers := make([]int, len(lineOffsets)-1)
|
||||
for i := range lineNumbers {
|
||||
lineNumbers[i] = i + 1
|
||||
}
|
||||
|
||||
// Collect all lines to display (+/- 1 line around each match)
|
||||
sortedLines := make([]int, 0, len(r.Matches)*3)
|
||||
for _, m := range r.Matches {
|
||||
for i := m.LineNumber - 1; i <= m.LineNumber+1; i++ {
|
||||
if i > 0 {
|
||||
sortedLines = append(sortedLines, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort lines and remove duplicates
|
||||
slices.Sort(sortedLines)
|
||||
sortedLines = slices.Compact(sortedLines)
|
||||
|
||||
// Group lines into blocks (break block if distance > 2 lines)
|
||||
var blocks [][]int
|
||||
var currentBlock []int
|
||||
for _, line := range sortedLines {
|
||||
if len(currentBlock) > 0 && line > currentBlock[len(currentBlock)-1]+2 {
|
||||
blocks = append(blocks, currentBlock)
|
||||
currentBlock = nil
|
||||
}
|
||||
currentBlock = append(currentBlock, line)
|
||||
}
|
||||
if len(currentBlock) > 0 {
|
||||
blocks = append(blocks, currentBlock)
|
||||
}
|
||||
|
||||
var resultLines []internal.ResultLine
|
||||
|
||||
// Iterate over blocks to generate ResultLines
|
||||
for _, block := range blocks {
|
||||
startLine := block[0]
|
||||
endLine := block[len(block)-1]
|
||||
|
||||
// Slice block content directly from r.Content using precomputed offsets
|
||||
startOffset := lineOffsets[startLine-1]
|
||||
endOffset := lineOffsets[endLine]
|
||||
blockContent := r.Content[startOffset:endOffset]
|
||||
|
||||
// Map for highlights per line within the block
|
||||
highlightByLine := make(map[int][][2]int)
|
||||
for _, match := range r.Matches {
|
||||
if match.LineNumber < startLine || match.LineNumber > endLine {
|
||||
continue
|
||||
}
|
||||
lineInBlock := match.LineNumber - startLine
|
||||
globalLineIdx := match.LineNumber - 1
|
||||
|
||||
highlightStart := match.Start - lineOffsets[globalLineIdx]
|
||||
highlightEnd := match.End - lineOffsets[globalLineIdx]
|
||||
|
||||
highlightByLine[lineInBlock] = append(highlightByLine[lineInBlock], [2]int{highlightStart, highlightEnd})
|
||||
}
|
||||
|
||||
// Merge overlapping highlight ranges
|
||||
var highlightRanges [][3]int
|
||||
for lineIdx, ranges := range highlightByLine {
|
||||
if len(ranges) == 0 {
|
||||
continue
|
||||
}
|
||||
slices.SortFunc(ranges, func(a, b [2]int) int { return a[0] - b[0] })
|
||||
merged := make([][2]int, 0, len(ranges))
|
||||
current := ranges[0]
|
||||
for _, r := range ranges[1:] {
|
||||
if r[0] <= current[1] {
|
||||
if r[1] > current[1] {
|
||||
current[1] = r[1]
|
||||
}
|
||||
} else {
|
||||
merged = append(merged, current)
|
||||
current = r
|
||||
}
|
||||
}
|
||||
merged = append(merged, current)
|
||||
|
||||
for _, r := range merged {
|
||||
highlightRanges = append(highlightRanges, [3]int{lineIdx, r[0], r[1]})
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the formatted lines with highlighting
|
||||
resultLines = append(resultLines, internal.HighlightSearchResultCode(
|
||||
r.Filename,
|
||||
block,
|
||||
highlightRanges,
|
||||
blockContent,
|
||||
)...)
|
||||
}
|
||||
|
||||
// Return the final search result
|
||||
return &internal.Result{
|
||||
RepoID: r.RepoID,
|
||||
Filename: r.Filename,
|
||||
CommitID: r.CommitID,
|
||||
UpdatedUnix: r.UpdatedUnix,
|
||||
Language: r.Language,
|
||||
Color: r.Color,
|
||||
Lines: resultLines,
|
||||
}, nil
|
||||
}
|
||||
42
modules/indexer/code/zoekt/zoekt_noop.go
Normal file
42
modules/indexer/code/zoekt/zoekt_noop.go
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build !unix
|
||||
|
||||
package zoekt
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
repo_model "forgejo.org/models/repo"
|
||||
"forgejo.org/modules/indexer/code/internal"
|
||||
indexer_internal "forgejo.org/modules/indexer/internal"
|
||||
inner_zoekt "forgejo.org/modules/indexer/internal/zoekt"
|
||||
)
|
||||
|
||||
type Indexer struct {
|
||||
indexer_internal.Indexer // do not composite inner_zoekt.Indexer directly to avoid exposing too much
|
||||
inner *inner_zoekt.Indexer
|
||||
}
|
||||
|
||||
func NewIndexer(_ string) *Indexer {
|
||||
idxer := inner_zoekt.NewIndexer()
|
||||
return &Indexer{
|
||||
Indexer: idxer,
|
||||
inner: idxer,
|
||||
}
|
||||
}
|
||||
|
||||
// Index will save the index data
|
||||
func (b *Indexer) Index(ctx context.Context, repo *repo_model.Repository, sha string, changes *internal.RepoChanges) error {
|
||||
return inner_zoekt.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Delete entries by repoId
|
||||
func (b *Indexer) Delete(_ context.Context, repoID int64) error {
|
||||
return inner_zoekt.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (b *Indexer) Search(ctx context.Context, opts *internal.SearchOptions) (int64, []*internal.SearchResult, []*internal.SearchResultLanguages, error) {
|
||||
return 0, nil, nil, inner_zoekt.ErrNotImplemented
|
||||
}
|
||||
152
modules/indexer/code/zoekt/zoekt_test.go
Normal file
152
modules/indexer/code/zoekt/zoekt_test.go
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
// Copyright 2026 The Forgejo Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package zoekt
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"forgejo.org/modules/indexer/code/internal"
|
||||
|
||||
"github.com/sourcegraph/zoekt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestConvertZoektResult_BasicMatch(t *testing.T) {
|
||||
content := "hello world\nsecond line\n"
|
||||
|
||||
files := []zoekt.FileMatch{
|
||||
{
|
||||
RepositoryID: 1,
|
||||
FileName: "main.go",
|
||||
Version: "commit123",
|
||||
Language: "Go",
|
||||
Content: []byte(content),
|
||||
LineMatches: []zoekt.LineMatch{
|
||||
{
|
||||
LineNumber: 1,
|
||||
LineFragments: []zoekt.LineFragmentMatch{
|
||||
{
|
||||
Offset: 6, // "world"
|
||||
MatchLength: 5,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
results := convertZoektResult(files)
|
||||
require.Len(t, results, 1)
|
||||
|
||||
res := results[0]
|
||||
|
||||
assert.Equal(t, int64(1), res.RepoID)
|
||||
assert.Equal(t, "main.go", res.Filename)
|
||||
assert.Equal(t, "commit123", res.CommitID)
|
||||
assert.Equal(t, "Go", res.Language)
|
||||
assert.Equal(t, content, res.Content)
|
||||
|
||||
require.Len(t, res.Matches, 1)
|
||||
assert.Equal(t, 6, res.Matches[0].Start)
|
||||
assert.Equal(t, 11, res.Matches[0].End)
|
||||
assert.Equal(t, 1, res.Matches[0].LineNumber)
|
||||
|
||||
assert.Equal(t, []int{1, 2, 3}, res.LineNumbers)
|
||||
assert.Equal(t, []int{0, 12, 24}, res.LineOffsets)
|
||||
}
|
||||
|
||||
func TestConvertZoektResult_PlainTextFallback(t *testing.T) {
|
||||
files := []zoekt.FileMatch{
|
||||
{
|
||||
RepositoryID: 2,
|
||||
FileName: "README",
|
||||
Version: "commit456",
|
||||
Content: []byte("just text"),
|
||||
LineMatches: []zoekt.LineMatch{
|
||||
{
|
||||
LineNumber: 1,
|
||||
LineFragments: []zoekt.LineFragmentMatch{
|
||||
{Offset: 0, MatchLength: 4},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
results := convertZoektResult(files)
|
||||
require.Len(t, results, 1)
|
||||
|
||||
assert.Equal(t, "Plain Text", results[0].Language)
|
||||
}
|
||||
|
||||
func TestGetSearchResultLanguages(t *testing.T) {
|
||||
searchResult := &zoekt.SearchResult{
|
||||
Files: []zoekt.FileMatch{
|
||||
{Language: "Go"},
|
||||
{Language: "Go"},
|
||||
{Language: "Rust"},
|
||||
{Language: ""},
|
||||
},
|
||||
}
|
||||
|
||||
stats := getSearchResultLanguages(searchResult)
|
||||
|
||||
require.Len(t, stats, 3)
|
||||
|
||||
assert.Equal(t, "Go", stats[0].Language)
|
||||
assert.Equal(t, 2, stats[0].Count)
|
||||
|
||||
assert.Equal(t, "Plain Text", stats[1].Language)
|
||||
assert.Equal(t, 1, stats[1].Count)
|
||||
|
||||
assert.Equal(t, "Rust", stats[2].Language)
|
||||
assert.Equal(t, 1, stats[2].Count)
|
||||
}
|
||||
|
||||
func TestGenerateZoektQuery_Union(t *testing.T) {
|
||||
indexer := &Indexer{}
|
||||
|
||||
opts := &internal.SearchOptions{
|
||||
Keyword: "foo bar",
|
||||
Mode: internal.CodeSearchModeUnion,
|
||||
RepoIDs: []int64{1, 2},
|
||||
}
|
||||
|
||||
q, err := indexer.generateZoektQuery(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, q)
|
||||
}
|
||||
|
||||
func TestGenerateZoektQuery_SpecialCharacters(t *testing.T) {
|
||||
indexer := &Indexer{}
|
||||
|
||||
opts := &internal.SearchOptions{
|
||||
Keyword: `foo.bar+baz[qux]`,
|
||||
Mode: internal.CodeSearchModeExact,
|
||||
}
|
||||
|
||||
q, err := indexer.generateZoektQuery(opts)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, q)
|
||||
}
|
||||
|
||||
func TestConvertZoektResult_IgnoresFilenameMatches(t *testing.T) {
|
||||
files := []zoekt.FileMatch{
|
||||
{
|
||||
RepositoryID: 1,
|
||||
FileName: "foo.go",
|
||||
Version: "commit123",
|
||||
Content: []byte("package main\n"),
|
||||
LineMatches: []zoekt.LineMatch{
|
||||
{
|
||||
FileName: true, // filename-only match
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
results := convertZoektResult(files)
|
||||
assert.Empty(t, results)
|
||||
}
|
||||
107
modules/indexer/internal/zoekt/indexer.go
Normal file
107
modules/indexer/internal/zoekt/indexer.go
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build unix
|
||||
|
||||
package zoekt
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"forgejo.org/modules/indexer/internal/zoekt/meta"
|
||||
"forgejo.org/modules/log"
|
||||
"forgejo.org/modules/util"
|
||||
|
||||
"github.com/sourcegraph/zoekt"
|
||||
"github.com/sourcegraph/zoekt/search"
|
||||
)
|
||||
|
||||
type Indexer struct {
|
||||
indexDir string
|
||||
Searcher zoekt.Streamer
|
||||
version int
|
||||
}
|
||||
|
||||
func NewIndexer(indexDir string, version int) *Indexer {
|
||||
return &Indexer{
|
||||
indexDir: indexDir,
|
||||
version: version,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Indexer) Init(_ context.Context) (bool, error) {
|
||||
exists := true
|
||||
|
||||
if _, err := os.Stat(i.indexDir); err != nil && os.IsNotExist(err) {
|
||||
exists = false
|
||||
err = os.MkdirAll(i.indexDir, 0o750)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to create index directory: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Info("Initializing zoekt indexer at %s", i.indexDir)
|
||||
metadata, err := meta.ReadIndexMetadata(i.indexDir)
|
||||
if err != nil {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
if err = meta.WriteIndexMetadata(i.indexDir, &meta.IndexMetadata{
|
||||
Version: i.version,
|
||||
}); err != nil {
|
||||
return false, fmt.Errorf("failed to write index metadata: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return false, err
|
||||
}
|
||||
if metadata.Version != i.version {
|
||||
compare := "older"
|
||||
if metadata.Version > i.version {
|
||||
compare = "newer"
|
||||
}
|
||||
|
||||
log.Warn("Found %s zoekt index with version %d, Forgejo will remove it and rebuild", compare, metadata.Version)
|
||||
|
||||
// the indexer is using a previous version, so we should delete it and
|
||||
// re-populate
|
||||
if err = util.RemoveAll(i.indexDir); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if _, err := os.Stat(i.indexDir); err != nil && os.IsNotExist(err) {
|
||||
exists = false
|
||||
err = os.MkdirAll(i.indexDir, 0o750)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to create index directory: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err = meta.WriteIndexMetadata(i.indexDir, &meta.IndexMetadata{
|
||||
Version: i.version,
|
||||
}); err != nil {
|
||||
return false, fmt.Errorf("failed to write index metadata: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
searcher, err := search.NewDirectorySearcherFast(i.indexDir)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
i.Searcher = searcher
|
||||
|
||||
return exists, nil
|
||||
}
|
||||
|
||||
func (i *Indexer) Ping(_ context.Context) error {
|
||||
// NOTHING TO DO
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *Indexer) Close() {
|
||||
if i.Searcher == nil {
|
||||
return
|
||||
}
|
||||
i.Searcher.Close()
|
||||
}
|
||||
31
modules/indexer/internal/zoekt/indexer_noop.go
Normal file
31
modules/indexer/internal/zoekt/indexer_noop.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build !unix
|
||||
|
||||
package zoekt
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
var ErrNotImplemented = errors.New("zoekt indexer is not supported on non-Unix systems")
|
||||
|
||||
type Indexer struct{}
|
||||
|
||||
func NewIndexer() *Indexer {
|
||||
return &Indexer{}
|
||||
}
|
||||
|
||||
func (i *Indexer) Init(_ context.Context) (bool, error) {
|
||||
return false, ErrNotImplemented
|
||||
}
|
||||
|
||||
func (i *Indexer) Ping(_ context.Context) error {
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (i *Indexer) Close() {
|
||||
// NOTHING TO DO
|
||||
}
|
||||
58
modules/indexer/internal/zoekt/meta/meta.go
Normal file
58
modules/indexer/internal/zoekt/meta/meta.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// Copyright 2025 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build unix
|
||||
|
||||
package meta
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"forgejo.org/modules/json"
|
||||
)
|
||||
|
||||
const metaFilename = "zoekt_meta.json"
|
||||
|
||||
func indexMetadataPath(dir string) string {
|
||||
return filepath.Join(dir, metaFilename)
|
||||
}
|
||||
|
||||
type IndexMetadata struct {
|
||||
Version int `json:"version"`
|
||||
}
|
||||
|
||||
func readJSON(path string, meta any) error {
|
||||
metaBytes, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(metaBytes, meta)
|
||||
}
|
||||
|
||||
func writeJSON(path string, meta any) error {
|
||||
metaBytes, err := json.Marshal(meta)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, metaBytes, 0o666)
|
||||
}
|
||||
|
||||
// ReadIndexMetadata returns the metadata for the index at the specified path.
|
||||
// If no such index metadata exists, an empty metadata and a nil error are
|
||||
// returned.
|
||||
func ReadIndexMetadata(path string) (*IndexMetadata, error) {
|
||||
meta := &IndexMetadata{}
|
||||
metaPath := indexMetadataPath(path)
|
||||
if _, err := os.Stat(metaPath); os.IsNotExist(err) {
|
||||
return meta, nil
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return meta, readJSON(metaPath, meta)
|
||||
}
|
||||
|
||||
// WriteIndexMetadata writes metadata for the index at the specified path.
|
||||
func WriteIndexMetadata(path string, meta *IndexMetadata) error {
|
||||
return writeJSON(indexMetadataPath(path), meta)
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ func loadIndexerFrom(rootCfg ConfigProvider) {
|
|||
Indexer.RepoIndexerRepoTypes = strings.Split(sec.Key("REPO_INDEXER_REPO_TYPES").MustString("sources,forks,mirrors,templates"), ",")
|
||||
Indexer.RepoIndexerEnableFuzzy = sec.Key("REPO_INDEXER_FUZZY_ENABLED").MustBool(false)
|
||||
Indexer.RepoType = sec.Key("REPO_INDEXER_TYPE").MustString("bleve")
|
||||
Indexer.RepoPath = filepath.ToSlash(sec.Key("REPO_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers/repos.bleve"))))
|
||||
Indexer.RepoPath = filepath.ToSlash(sec.Key("REPO_INDEXER_PATH").MustString(filepath.ToSlash(filepath.Join(AppDataPath, "indexers", "repos."+Indexer.RepoType))))
|
||||
if !filepath.IsAbs(Indexer.RepoPath) {
|
||||
Indexer.RepoPath = filepath.ToSlash(filepath.Join(AppWorkPath, Indexer.RepoPath))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue