mirror of
https://github.com/go-gitea/gitea
synced 2025-09-10 18:58:27 +00:00
Upgrade dependencies (#35384)
- ~Upgrade golang to 1.25~ blocked by the issue https://github.com/go-swagger/go-swagger/issues/3220 - Upgrade minor versions of most dependencies - Upgrade github.com/google/go-github version to v74 - Fix meilisearch because of sdk interface change - Use github.com/Necoro/html2text which is a fork instead of html2text because of https://github.com/jaytaylor/html2text/issues/67 which resulted in complie failure. - Fix some deprecated methods of gitlab go client.
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
|
||||
inner_meilisearch "code.gitea.io/gitea/modules/indexer/internal/meilisearch"
|
||||
"code.gitea.io/gitea/modules/indexer/issues/internal"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
)
|
||||
@@ -106,7 +107,8 @@ func (b *Indexer) Index(_ context.Context, issues ...*internal.IndexerData) erro
|
||||
return nil
|
||||
}
|
||||
for _, issue := range issues {
|
||||
_, err := b.inner.Client.Index(b.inner.VersionedIndexName()).AddDocuments(issue)
|
||||
// use default primary key which should be "id"
|
||||
_, err := b.inner.Client.Index(b.inner.VersionedIndexName()).AddDocuments(issue, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -299,18 +301,13 @@ func doubleQuoteKeyword(k string) string {
|
||||
func convertHits(searchRes *meilisearch.SearchResponse) ([]internal.Match, error) {
|
||||
hits := make([]internal.Match, 0, len(searchRes.Hits))
|
||||
for _, hit := range searchRes.Hits {
|
||||
hit, ok := hit.(map[string]any)
|
||||
if !ok {
|
||||
return nil, ErrMalformedResponse
|
||||
}
|
||||
|
||||
issueID, ok := hit["id"].(float64)
|
||||
if !ok {
|
||||
var issueID int64
|
||||
if err := json.Unmarshal(hit["id"], &issueID); err != nil {
|
||||
return nil, ErrMalformedResponse
|
||||
}
|
||||
|
||||
hits = append(hits, internal.Match{
|
||||
ID: int64(issueID),
|
||||
ID: issueID,
|
||||
})
|
||||
}
|
||||
return hits, nil
|
||||
|
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"code.gitea.io/gitea/modules/indexer/issues/internal"
|
||||
"code.gitea.io/gitea/modules/indexer/issues/internal/tests"
|
||||
"code.gitea.io/gitea/modules/json"
|
||||
|
||||
"github.com/meilisearch/meilisearch-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -45,30 +46,42 @@ func TestMeilisearchIndexer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestConvertHits(t *testing.T) {
|
||||
convert := func(d any) []byte {
|
||||
b, _ := json.Marshal(d)
|
||||
return b
|
||||
}
|
||||
|
||||
_, err := convertHits(&meilisearch.SearchResponse{
|
||||
Hits: []any{"aa", "bb", "cc", "dd"},
|
||||
Hits: []meilisearch.Hit{
|
||||
{
|
||||
"aa": convert(1),
|
||||
"bb": convert(2),
|
||||
"cc": convert(3),
|
||||
"dd": convert(4),
|
||||
},
|
||||
},
|
||||
})
|
||||
assert.ErrorIs(t, err, ErrMalformedResponse)
|
||||
|
||||
validResponse := &meilisearch.SearchResponse{
|
||||
Hits: []any{
|
||||
map[string]any{
|
||||
"id": float64(11),
|
||||
"title": "a title",
|
||||
"content": "issue body with no match",
|
||||
"comments": []any{"hey whats up?", "I'm currently bowling", "nice"},
|
||||
Hits: []meilisearch.Hit{
|
||||
{
|
||||
"id": convert(float64(11)),
|
||||
"title": convert("a title"),
|
||||
"content": convert("issue body with no match"),
|
||||
"comments": convert([]any{"hey whats up?", "I'm currently bowling", "nice"}),
|
||||
},
|
||||
map[string]any{
|
||||
"id": float64(22),
|
||||
"title": "Bowling as title",
|
||||
"content": "",
|
||||
"comments": []any{},
|
||||
{
|
||||
"id": convert(float64(22)),
|
||||
"title": convert("Bowling as title"),
|
||||
"content": convert(""),
|
||||
"comments": convert([]any{}),
|
||||
},
|
||||
map[string]any{
|
||||
"id": float64(33),
|
||||
"title": "Bowl-ing as fuzzy match",
|
||||
"content": "",
|
||||
"comments": []any{},
|
||||
{
|
||||
"id": convert(float64(33)),
|
||||
"title": convert("Bowl-ing as fuzzy match"),
|
||||
"content": convert(""),
|
||||
"comments": convert([]any{}),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user