refactor(completion): complete assignees and tags through the SDK

Completion fetched repository assignees and tags with raw GETs. List them
through new Repositories.Assignees and Repositories.Tags service methods on
the SDK, and remove the raw fetch helper.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-12 09:55:36 +02:00
1 parent ae0ea27bb0
commit 03aa64233f
3 files changed
+46 -32

No files matched your search

+27 -3
View File
@@ -145,15 +145,39 @@ func (s Repositories) viewPermissions(ctx context.Context, repo string) (Reposit
return RepositoryPermissions{Admin: item.Permissions.Admin, Push: item.Permissions.Push, Pull: item.Permissions.Pull}, nil
}
// assignees lists usernames that can be assigned on repository issues.
func (s Repositories) assignees(ctx context.Context, repo string) ([]string, error) {
// Assignee is a user that can be assigned on repository issues.
type Assignee struct {
Username string `json:"username"`
FullName string `json:"full_name"`
}
// Assignees lists the users that can be assigned on repository issues.
func (s Repositories) Assignees(ctx context.Context, repo string) ([]Assignee, error) {
users, err := repoCall(ctx, s.Client, repo, func(ctx context.Context, c *gitea.Client, owner, name string) ([]*gitea.User, *gitea.Response, error) {
return c.Repositories.GetAssignees(ctx, owner, name)
})
return convertAll(users, func(user *gitea.User) Assignee { return Assignee{Username: user.UserName, FullName: user.FullName} }), err
}
// assignees lists usernames that can be assigned on repository issues.
func (s Repositories) assignees(ctx context.Context, repo string) ([]string, error) {
users, err := s.Assignees(ctx, repo)
if err != nil {
return nil, err
}
return convertAll(users, login), nil
names := make([]string, len(users))
for i, user := range users {
names[i] = user.Username
}
return names, nil
}
// Tags lists a page of the repository's tag names.
func (s Repositories) Tags(ctx context.Context, repo string, limit, page int) ([]string, error) {
tags, err := repoCall(ctx, s.Client, repo, func(ctx context.Context, c *gitea.Client, owner, name string) ([]*gitea.Tag, *gitea.Response, error) {
return c.Repositories.ListRepoTags(ctx, owner, name, gitea.ListRepoTagsOptions{ListOptions: listOptions(limit, page)})
})
return convertAll(tags, func(tag *gitea.Tag) string { return tag.Name }), err
}
// Create creates a repository for the account or the named organization.