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:
bircni committed 2026-10-12 11:22:52 +02:00
1 parent 29f62da006
commit 83924892ff
33 files changed
+85 -212

No files matched your search

-27
View File
@@ -5,36 +5,9 @@ package services
import (
"context"
"fmt"
"strconv"
"strings"
)
// ResolveName selects an exact title across open and closed milestones.
func (s Milestones) ResolveName(ctx context.Context, name string) (int64, error) {
if strings.TrimSpace(name) == "" {
return 0, fmt.Errorf("milestone name cannot be empty")
}
items, err := s.All(ctx)
if err != nil {
return 0, err
}
var id int64
for _, item := range items {
if item.Title != name {
continue
}
if id != 0 {
return 0, fmt.Errorf("milestone name %q is ambiguous; select its numeric ID", name)
}
id = item.ID
}
if id == 0 {
return 0, fmt.Errorf("milestone %q does not exist; use tea milestone list --state all", name)
}
return id, nil
}
// All returns the open and closed milestones of the repository.
func (s Milestones) All(ctx context.Context) ([]Milestone, error) {
return listAll(func(page int) ([]Milestone, error) { return s.List(ctx, "all", 100, page) })