Skip to content

Commit e96ef97

Browse files
authored
Upgrade dependencies (#35384)
- ~Upgrade golang to 1.25~ blocked by the issue go-swagger/go-swagger#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 jaytaylor/html2text#67 which resulted in complie failure. - Fix some deprecated methods of gitlab go client.
1 parent 086ff87 commit e96ef97

File tree

11 files changed

+352
-308
lines changed

11 files changed

+352
-308
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
3131
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/[email protected]
32-
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected].12
32+
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected].15
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
3535
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest

assets/go-licenses.json

Lines changed: 27 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/backport/backport.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"strconv"
1717
"strings"
1818

19-
"github.com/google/go-github/v71/github"
19+
"github.com/google/go-github/v74/github"
2020
"github.com/urfave/cli/v3"
2121
"gopkg.in/yaml.v3"
2222
)

go.mod

Lines changed: 91 additions & 84 deletions
Large diffs are not rendered by default.

go.sum

Lines changed: 190 additions & 182 deletions
Large diffs are not rendered by default.

modules/indexer/issues/meilisearch/meilisearch.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
indexer_internal "code.gitea.io/gitea/modules/indexer/internal"
1515
inner_meilisearch "code.gitea.io/gitea/modules/indexer/internal/meilisearch"
1616
"code.gitea.io/gitea/modules/indexer/issues/internal"
17+
"code.gitea.io/gitea/modules/json"
1718

1819
"github.com/meilisearch/meilisearch-go"
1920
)
@@ -106,7 +107,8 @@ func (b *Indexer) Index(_ context.Context, issues ...*internal.IndexerData) erro
106107
return nil
107108
}
108109
for _, issue := range issues {
109-
_, err := b.inner.Client.Index(b.inner.VersionedIndexName()).AddDocuments(issue)
110+
// use default primary key which should be "id"
111+
_, err := b.inner.Client.Index(b.inner.VersionedIndexName()).AddDocuments(issue, nil)
110112
if err != nil {
111113
return err
112114
}
@@ -299,18 +301,13 @@ func doubleQuoteKeyword(k string) string {
299301
func convertHits(searchRes *meilisearch.SearchResponse) ([]internal.Match, error) {
300302
hits := make([]internal.Match, 0, len(searchRes.Hits))
301303
for _, hit := range searchRes.Hits {
302-
hit, ok := hit.(map[string]any)
303-
if !ok {
304-
return nil, ErrMalformedResponse
305-
}
306-
307-
issueID, ok := hit["id"].(float64)
308-
if !ok {
304+
var issueID int64
305+
if err := json.Unmarshal(hit["id"], &issueID); err != nil {
309306
return nil, ErrMalformedResponse
310307
}
311308

312309
hits = append(hits, internal.Match{
313-
ID: int64(issueID),
310+
ID: issueID,
314311
})
315312
}
316313
return hits, nil

modules/indexer/issues/meilisearch/meilisearch_test.go

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"code.gitea.io/gitea/modules/indexer/issues/internal"
1414
"code.gitea.io/gitea/modules/indexer/issues/internal/tests"
15+
"code.gitea.io/gitea/modules/json"
1516

1617
"github.com/meilisearch/meilisearch-go"
1718
"github.com/stretchr/testify/assert"
@@ -45,30 +46,42 @@ func TestMeilisearchIndexer(t *testing.T) {
4546
}
4647

4748
func TestConvertHits(t *testing.T) {
49+
convert := func(d any) []byte {
50+
b, _ := json.Marshal(d)
51+
return b
52+
}
53+
4854
_, err := convertHits(&meilisearch.SearchResponse{
49-
Hits: []any{"aa", "bb", "cc", "dd"},
55+
Hits: []meilisearch.Hit{
56+
{
57+
"aa": convert(1),
58+
"bb": convert(2),
59+
"cc": convert(3),
60+
"dd": convert(4),
61+
},
62+
},
5063
})
5164
assert.ErrorIs(t, err, ErrMalformedResponse)
5265

5366
validResponse := &meilisearch.SearchResponse{
54-
Hits: []any{
55-
map[string]any{
56-
"id": float64(11),
57-
"title": "a title",
58-
"content": "issue body with no match",
59-
"comments": []any{"hey whats up?", "I'm currently bowling", "nice"},
67+
Hits: []meilisearch.Hit{
68+
{
69+
"id": convert(float64(11)),
70+
"title": convert("a title"),
71+
"content": convert("issue body with no match"),
72+
"comments": convert([]any{"hey whats up?", "I'm currently bowling", "nice"}),
6073
},
61-
map[string]any{
62-
"id": float64(22),
63-
"title": "Bowling as title",
64-
"content": "",
65-
"comments": []any{},
74+
{
75+
"id": convert(float64(22)),
76+
"title": convert("Bowling as title"),
77+
"content": convert(""),
78+
"comments": convert([]any{}),
6679
},
67-
map[string]any{
68-
"id": float64(33),
69-
"title": "Bowl-ing as fuzzy match",
70-
"content": "",
71-
"comments": []any{},
80+
{
81+
"id": convert(float64(33)),
82+
"title": convert("Bowl-ing as fuzzy match"),
83+
"content": convert(""),
84+
"comments": convert([]any{}),
7285
},
7386
},
7487
}

services/migrations/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package migrations
77
import (
88
"errors"
99

10-
"github.com/google/go-github/v71/github"
10+
"github.com/google/go-github/v74/github"
1111
)
1212

1313
// ErrRepoNotCreated returns the error that repository not created

services/migrations/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"code.gitea.io/gitea/modules/proxy"
2121
"code.gitea.io/gitea/modules/structs"
2222

23-
"github.com/google/go-github/v71/github"
23+
"github.com/google/go-github/v74/github"
2424
"golang.org/x/oauth2"
2525
)
2626

services/migrations/gitlab.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (f *GitlabDownloaderFactory) New(ctx context.Context, opts base.MigrateOpti
5050

5151
log.Trace("Create gitlab downloader. BaseURL: %s RepoName: %s", baseURL, repoNameSpace)
5252

53-
return NewGitlabDownloader(ctx, baseURL, repoNameSpace, opts.AuthUsername, opts.AuthPassword, opts.AuthToken)
53+
return NewGitlabDownloader(ctx, baseURL, repoNameSpace, opts.AuthToken)
5454
}
5555

5656
// GitServiceType returns the type of git service
@@ -93,14 +93,8 @@ type GitlabDownloader struct {
9393
//
9494
// Use either a username/password, personal token entered into the username field, or anonymous/public access
9595
// Note: Public access only allows very basic access
96-
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error) {
96+
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, token string) (*GitlabDownloader, error) {
9797
gitlabClient, err := gitlab.NewClient(token, gitlab.WithBaseURL(baseURL), gitlab.WithHTTPClient(NewMigrationHTTPClient()))
98-
// Only use basic auth if token is blank and password is NOT
99-
// Basic auth will fail with empty strings, but empty token will allow anonymous public API usage
100-
if token == "" && password != "" {
101-
gitlabClient, err = gitlab.NewBasicAuthClient(username, password, gitlab.WithBaseURL(baseURL), gitlab.WithHTTPClient(NewMigrationHTTPClient()))
102-
}
103-
10498
if err != nil {
10599
log.Trace("Error logging into gitlab: %v", err)
106100
return nil, err
@@ -206,7 +200,7 @@ func (g *GitlabDownloader) GetTopics(ctx context.Context) ([]string, error) {
206200
if err != nil {
207201
return nil, err
208202
}
209-
return gr.TagList, err
203+
return gr.Topics, err
210204
}
211205

212206
// GetMilestones returns milestones

0 commit comments

Comments
 (0)