mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix: page hint for comment list, keep SSH settings on re-login, hard-link-free downloads, stable OWNER/REPO#N instance (follow gh)
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
11 files changed
+154
-10
No files matched your search
@@ -53,12 +53,16 @@ func (s Comments) List(ctx context.Context, n int64) ([]Comment, error) {
|
||||
}
|
||||
|
||||
// Page applies CLI pagination to the unpaginated comment collection.
|
||||
func (s Comments) Page(ctx context.Context, n int64, limit, page int) ([]Comment, error) {
|
||||
func (s Comments) Page(ctx context.Context, n int64, limit, page int) (Page[Comment], error) {
|
||||
items, err := s.List(ctx, n)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return Page[Comment]{}, err
|
||||
}
|
||||
return pageOf(items, limit, page)
|
||||
window, err := pageOf(items, limit, page)
|
||||
if err != nil {
|
||||
return Page[Comment]{}, err
|
||||
}
|
||||
return Page[Comment]{Items: window, More: len(items) > page*limit, Total: len(items), Counted: true}, nil
|
||||
}
|
||||
|
||||
// NotPlainCommentError reports a comment that the single-comment endpoint answers with no body,
|
||||
|
||||
@@ -34,12 +34,17 @@ func TestCommentPaginationIsLocal(t *testing.T) {
|
||||
service := Comments{Client: client, Repository: "alice/project"}
|
||||
items, err := service.Page(context.Background(), 7, 2, 2)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, items, 1)
|
||||
require.Equal(t, int64(3), items[0].ID)
|
||||
require.Len(t, items.Items, 1)
|
||||
require.Equal(t, int64(3), items.Items[0].ID)
|
||||
require.False(t, items.More)
|
||||
first, err := service.Page(context.Background(), 7, 2, 1)
|
||||
require.NoError(t, err)
|
||||
require.True(t, first.More)
|
||||
require.Equal(t, 3, first.Total)
|
||||
items, err = service.Page(context.Background(), 7, 2, 3)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, items)
|
||||
require.NotNil(t, items)
|
||||
require.Empty(t, items.Items)
|
||||
require.NotNil(t, items.Items)
|
||||
item, err := service.Create(context.Background(), 7, "text")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "alice", item.Author)
|
||||
|
||||
Reference in new issue
Block a user