mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
refactor: reuse the existing service and rendering helpers
services.IsNotFound replaces the hand-rolled 404 checks, convertPage the copied page conversions and lastPathNumber the comment's own number parser. The List wrappers around ListPage of releases, branches, wiki pages, secrets and variables go, pull request filters resolve milestones through Milestones.FindOne like issues, and localFlagsChanged, boolOrder, Cell.Render, stateBadge and dueText replace their copies. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
33 files changed
+85
-212
No files matched your search
@@ -385,8 +385,8 @@ func (a *application) completeUsers() cobra.CompletionFunc {
|
||||
// completeBranches completes the local branches, then the repository's branches.
|
||||
func (a *application) completeBranches() cobra.CompletionFunc {
|
||||
return mergeCompletions(a.completeLocalBranches, a.apiCompletion(true, func(ctx context.Context, t target, _ string) ([]cobra.Completion, error) {
|
||||
items, err := services.Branches{Client: t.client}.List(ctx, t.Repo, completionLimit, 1)
|
||||
return describe(items, func(item services.Branch) (string, string) {
|
||||
items, err := services.Branches{Client: t.client}.ListPage(ctx, t.Repo, completionLimit, 1)
|
||||
return describe(items.Items, func(item services.Branch) (string, string) {
|
||||
if item.Protected {
|
||||
return item.Name, "protected"
|
||||
}
|
||||
@@ -406,8 +406,8 @@ func (a *application) completeTags() cobra.CompletionFunc {
|
||||
// completeReleases completes release tags with their titles.
|
||||
func (a *application) completeReleases() cobra.CompletionFunc {
|
||||
return a.apiCompletion(true, func(ctx context.Context, t target, _ string) ([]cobra.Completion, error) {
|
||||
items, err := services.Releases{Client: t.client, Repository: t.Repo}.List(ctx, completionLimit, 1)
|
||||
return describe(items, func(item services.Release) (string, string) { return item.Tag, item.Title }), err
|
||||
items, err := services.Releases{Client: t.client, Repository: t.Repo}.ListPage(ctx, completionLimit, 1)
|
||||
return describe(items.Items, func(item services.Release) (string, string) { return item.Tag, item.Title }), err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -493,8 +493,8 @@ func (a *application) completeRuns() cobra.CompletionFunc {
|
||||
// organization or account selects the repository.
|
||||
func (a *application) completeSecrets(scope func() services.ActionScope) cobra.CompletionFunc {
|
||||
return a.apiCompletion(true, func(ctx context.Context, t target, _ string) ([]cobra.Completion, error) {
|
||||
items, err := services.ActionSecrets{Client: t.client, Scope: actionScope(scope, t)}.List(ctx, completionLimit, 1)
|
||||
return describe(items, func(item services.ActionSecret) (string, string) { return item.Name, item.Description }), err
|
||||
items, err := services.ActionSecrets{Client: t.client, Scope: actionScope(scope, t)}.ListPage(ctx, completionLimit, 1)
|
||||
return describe(items.Items, func(item services.ActionSecret) (string, string) { return item.Name, item.Description }), err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -502,8 +502,8 @@ func (a *application) completeSecrets(scope func() services.ActionScope) cobra.C
|
||||
// an organization or account selects the repository.
|
||||
func (a *application) completeVariables(scope func() services.ActionScope) cobra.CompletionFunc {
|
||||
return a.apiCompletion(true, func(ctx context.Context, t target, _ string) ([]cobra.Completion, error) {
|
||||
items, err := services.ActionVariables{Client: t.client, Scope: actionScope(scope, t)}.List(ctx, completionLimit, 1)
|
||||
return describe(items, func(item services.ActionVariable) (string, string) { return item.Name, item.Description }), err
|
||||
items, err := services.ActionVariables{Client: t.client, Scope: actionScope(scope, t)}.ListPage(ctx, completionLimit, 1)
|
||||
return describe(items.Items, func(item services.ActionVariable) (string, string) { return item.Name, item.Description }), err
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user