mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: reconcile the pull request stream
Share one shortSHA helper, keep Markdown raw in view tests through the markdown preference, and drop rawWindow now that pull request lists use the paged helpers. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
5 files changed
+11
-25
No files matched your search
@@ -10,8 +10,6 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"gitea.dev/tea/internal/transport"
|
||||
)
|
||||
@@ -39,20 +37,6 @@ func sendJSON(ctx context.Context, client *transport.Client, method, endpoint st
|
||||
return err
|
||||
}
|
||||
|
||||
// rawWindow is listWindow over a raw JSON collection endpoint; it sets limit and page on query.
|
||||
func rawWindow[T any](ctx context.Context, client *transport.Client, endpoint string, query url.Values, limit, page int) ([]T, bool, error) {
|
||||
if query == nil {
|
||||
query = url.Values{}
|
||||
}
|
||||
return listWindow(limit, page, func(limit, page int) ([]T, http.Header, error) {
|
||||
query.Set("limit", strconv.Itoa(limit))
|
||||
query.Set("page", strconv.Itoa(page))
|
||||
var response []T
|
||||
headers, err := rawJSON(ctx, client, http.MethodGet, endpoint+"?"+query.Encode(), nil, &response)
|
||||
return response, headers, err
|
||||
})
|
||||
}
|
||||
|
||||
func rawJSON(ctx context.Context, client *transport.Client, method, endpoint string, body io.Reader, out any) (http.Header, error) {
|
||||
resp, err := client.Do(ctx, method, endpoint, body, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user