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
@@ -5,7 +5,6 @@ package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
gitea "gitea.dev/sdk"
|
||||
@@ -30,19 +29,10 @@ func commentFrom(comment *gitea.Comment) Comment {
|
||||
return Comment{
|
||||
ID: comment.ID, Body: comment.Body, URL: comment.HTMLURL, Author: login(comment.Poster),
|
||||
CreatedAt: timestamp(comment.Created), UpdatedAt: timestamp(comment.Updated), Pull: comment.PRURL != "",
|
||||
IssueNumber: discussionNumber(comment.IssueURL + comment.PRURL),
|
||||
IssueNumber: lastPathNumber(comment.IssueURL + comment.PRURL),
|
||||
}
|
||||
}
|
||||
|
||||
// discussionNumber reads the number from the web URL of an issue or pull request, or returns 0.
|
||||
func discussionNumber(url string) int64 {
|
||||
n, err := strconv.ParseInt(path.Base(url), 10, 64)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
// Comments implements discussion comments under their owning repository resource.
|
||||
type Comments struct {
|
||||
Client *transport.Client
|
||||
|
||||
Reference in new issue
Block a user