Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AIR_PACKAGE ?= github.com/air-verse/air@v1
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/[email protected]
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected].12
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected].15
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
Expand Down
29 changes: 27 additions & 2 deletions assets/go-licenses.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contrib/backport/backport.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"strconv"
"strings"

"github.com/google/go-github/v71/github"
"github.com/google/go-github/v74/github"
"github.com/urfave/cli/v3"
"gopkg.in/yaml.v3"
)
Expand Down
175 changes: 91 additions & 84 deletions go.mod

Large diffs are not rendered by default.

372 changes: 190 additions & 182 deletions go.sum

Large diffs are not rendered by default.

15 changes: 6 additions & 9 deletions modules/indexer/issues/meilisearch/meilisearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
47 changes: 30 additions & 17 deletions modules/indexer/issues/meilisearch/meilisearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{}),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion services/migrations/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package migrations
import (
"errors"

"github.com/google/go-github/v71/github"
"github.com/google/go-github/v74/github"
)

// ErrRepoNotCreated returns the error that repository not created
Expand Down
2 changes: 1 addition & 1 deletion services/migrations/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"code.gitea.io/gitea/modules/proxy"
"code.gitea.io/gitea/modules/structs"

"github.com/google/go-github/v71/github"
"github.com/google/go-github/v74/github"
"golang.org/x/oauth2"
)

Expand Down
12 changes: 3 additions & 9 deletions services/migrations/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (f *GitlabDownloaderFactory) New(ctx context.Context, opts base.MigrateOpti

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

return NewGitlabDownloader(ctx, baseURL, repoNameSpace, opts.AuthUsername, opts.AuthPassword, opts.AuthToken)
return NewGitlabDownloader(ctx, baseURL, repoNameSpace, opts.AuthToken)
}

// GitServiceType returns the type of git service
Expand Down Expand Up @@ -93,14 +93,8 @@ type GitlabDownloader struct {
//
// Use either a username/password, personal token entered into the username field, or anonymous/public access
// Note: Public access only allows very basic access
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, username, password, token string) (*GitlabDownloader, error) {
func NewGitlabDownloader(ctx context.Context, baseURL, repoPath, token string) (*GitlabDownloader, error) {
gitlabClient, err := gitlab.NewClient(token, gitlab.WithBaseURL(baseURL), gitlab.WithHTTPClient(NewMigrationHTTPClient()))
// Only use basic auth if token is blank and password is NOT
// Basic auth will fail with empty strings, but empty token will allow anonymous public API usage
if token == "" && password != "" {
gitlabClient, err = gitlab.NewBasicAuthClient(username, password, gitlab.WithBaseURL(baseURL), gitlab.WithHTTPClient(NewMigrationHTTPClient()))
}

if err != nil {
log.Trace("Error logging into gitlab: %v", err)
return nil, err
Expand Down Expand Up @@ -206,7 +200,7 @@ func (g *GitlabDownloader) GetTopics(ctx context.Context) ([]string, error) {
if err != nil {
return nil, err
}
return gr.TagList, err
return gr.Topics, err
}

// GetMilestones returns milestones
Expand Down
2 changes: 1 addition & 1 deletion services/migrations/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
t.Skipf("Can't access test repo, skipping %s", t.Name())
}
ctx := t.Context()
downloader, err := NewGitlabDownloader(ctx, "https://gitlab.com", "gitea/test_repo", "", "", gitlabPersonalAccessToken)
downloader, err := NewGitlabDownloader(ctx, "https://gitlab.com", "gitea/test_repo", gitlabPersonalAccessToken)
if err != nil {
t.Fatalf("NewGitlabDownloader is nil: %v", err)
}
Expand Down