Add option to limit the resultset returned by paginate helper (#4475)

This commit is contained in:
Robert Kaussow
2024-11-29 10:39:01 +01:00
committed by GitHub
parent a949949ca0
commit 359e3af817
7 changed files with 96 additions and 33 deletions

View File

@@ -143,7 +143,7 @@ func (c *config) Teams(ctx context.Context, u *model.User) ([]*model.Team, error
return nil, err
}
return convertWorkspaceList(resp.Values), nil
})
}, -1)
}
// Repo returns the named Bitbucket repository.
@@ -190,7 +190,7 @@ func (c *config) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error
return nil, err
}
return resp.Values, nil
})
}, -1)
if err != nil {
return nil, err
}
@@ -331,7 +331,7 @@ func (c *config) Deactivate(ctx context.Context, u *model.User, r *model.Repo, l
return nil, err
}
return hooks.Values, nil
})
}, -1)
if err != nil {
return err
}

View File

@@ -115,7 +115,7 @@ func (c *Client) ListReposAll(workspace string) ([]*Repo, error) {
return nil, err
}
return resp.Values, nil
})
}, -1)
}
func (c *Client) FindHook(owner, name, id string) (*Hook, error) {
@@ -183,7 +183,7 @@ func (c *Client) ListPermissionsAll() ([]*RepoPerm, error) {
return nil, err
}
return resp.Values, nil
})
}, -1)
}
func (c *Client) ListBranches(owner, name string, opts *ListOpts) ([]*Branch, error) {

View File

@@ -201,7 +201,7 @@ func (c *Forgejo) Teams(ctx context.Context, u *model.User) ([]*model.Team, erro
teams = append(teams, toTeam(org, c.url))
}
return teams, err
})
}, -1)
}
// TeamPerm is not supported by the Forgejo driver.
@@ -253,7 +253,7 @@ func (c *Forgejo) Repos(ctx context.Context, u *model.User) ([]*model.Repo, erro
},
)
return repos, err
})
}, -1)
result := make([]*model.Repo, 0, len(repos))
for _, repo := range repos {
@@ -411,7 +411,7 @@ func (c *Forgejo) Deactivate(ctx context.Context, u *model.User, r *model.Repo,
},
})
return hooks, err
})
}, -1)
if err != nil {
return err
}
@@ -647,7 +647,7 @@ func (c *Forgejo) getChangedFilesForPR(ctx context.Context, repo *model.Repo, in
files = append(files, file.Filename)
}
return files, nil
})
}, -1)
}
func (c *Forgejo) getTagCommitSHA(ctx context.Context, repo *model.Repo, tagName string) (string, error) {

View File

@@ -203,7 +203,7 @@ func (c *Gitea) Teams(ctx context.Context, u *model.User) ([]*model.Team, error)
teams = append(teams, toTeam(org, c.url))
}
return teams, err
})
}, -1)
}
// TeamPerm is not supported by the Gitea driver.
@@ -255,7 +255,7 @@ func (c *Gitea) Repos(ctx context.Context, u *model.User) ([]*model.Repo, error)
},
)
return repos, err
})
}, -1)
result := make([]*model.Repo, 0, len(repos))
for _, repo := range repos {
@@ -413,7 +413,7 @@ func (c *Gitea) Deactivate(ctx context.Context, u *model.User, r *model.Repo, li
},
})
return hooks, err
})
}, -1)
if err != nil {
return err
}
@@ -654,7 +654,7 @@ func (c *Gitea) getChangedFilesForPR(ctx context.Context, repo *model.Repo, inde
files = append(files, file.Filename)
}
return files, nil
})
}, -1)
}
func (c *Gitea) getTagCommitSHA(ctx context.Context, repo *model.Repo, tagName string) (string, error) {

View File

@@ -660,7 +660,7 @@ func (c *client) loadChangedFilesFromPullRequest(ctx context.Context, pull *gith
opts.Page = resp.NextPage
}
return utils.DeduplicateStrings(fileList), nil
})
}, -1)
return pipeline, err
}