mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11: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
@@ -55,13 +55,7 @@ type Releases struct {
|
||||
|
||||
func (s Releases) endpoint() string { return "repos/" + s.Repository + "/releases" }
|
||||
|
||||
// List returns a non-nil page of releases.
|
||||
func (s Releases) List(ctx context.Context, limit, page int) ([]Release, error) {
|
||||
window, err := s.ListPage(ctx, limit, page)
|
||||
return window.Items, err
|
||||
}
|
||||
|
||||
// ListPage is List that also reports whether more releases follow and how many there are.
|
||||
// ListPage lists a page of releases, with whether more follow and how many there are.
|
||||
func (s Releases) ListPage(ctx context.Context, limit, page int) (Page[Release], error) {
|
||||
window, err := listPage(limit, page, func(limit, page int) ([]*gitea.Release, http.Header, error) {
|
||||
var headers http.Header
|
||||
@@ -75,7 +69,7 @@ func (s Releases) ListPage(ctx context.Context, limit, page int) (Page[Release],
|
||||
if err != nil {
|
||||
return Page[Release]{}, err
|
||||
}
|
||||
return Page[Release]{Items: convertAll(window.Items, releaseFrom), More: window.More, Total: window.Total, Counted: window.Counted}, nil
|
||||
return convertPage(window, releaseFrom), nil
|
||||
}
|
||||
|
||||
// View retrieves a release by its tag, including numeric tags.
|
||||
|
||||
Reference in new issue
Block a user