fix(review round 1): daemon PAT-header auth, job pruning, session-split batches, streaming tars, seed cleanup, ping/pong, byte caps, branch switch, slug --, ctx cancel, Init:true, pagination, latest/before events; web newest-window history + load-older, offline busy gate, staleness guards, memo store, auth probe, scroll key, focus-visible, draft restore, poll dedup; 106+181 tests, coverage 96.2%/95.1%+
This commit is contained in:
+25
-18
@@ -18,6 +18,7 @@ import (
|
||||
const (
|
||||
settingGitLabToken string = "gitlab_pat"
|
||||
projectsPerPage int = 50
|
||||
maxRepoPages int = 5 // pagination cap: 5 pages / 250 repos
|
||||
gitlabTimeout time.Duration = 15 * time.Second
|
||||
)
|
||||
|
||||
@@ -133,30 +134,36 @@ func (g *GitLab) token() (string, error) {
|
||||
return token, nil
|
||||
}
|
||||
|
||||
// Repos lists member projects sorted by most recent activity.
|
||||
// Repos lists member projects sorted by most recent activity, paging
|
||||
// upstream until a short page (capped at maxRepoPages).
|
||||
func (g *GitLab) Repos(ctx context.Context) ([]GitLabRepo, error) {
|
||||
token, err := g.token()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var projects []giteaRepo
|
||||
path := fmt.Sprintf("/api/v1/user/repos?limit=%d", projectsPerPage)
|
||||
if err := g.do(ctx, path, token, &projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
repos := make([]GitLabRepo, 0, len(projects))
|
||||
for _, p := range projects {
|
||||
if p.FullName == "" {
|
||||
continue
|
||||
var repos []GitLabRepo
|
||||
for page := 1; page <= maxRepoPages; page++ {
|
||||
path := fmt.Sprintf("/api/v1/user/repos?limit=%d&page=%d", projectsPerPage, page)
|
||||
var projects []giteaRepo
|
||||
if err := g.do(ctx, path, token, &projects); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, p := range projects {
|
||||
if p.FullName == "" {
|
||||
continue
|
||||
}
|
||||
repos = append(repos, GitLabRepo{
|
||||
Path: p.FullName,
|
||||
Name: p.Name,
|
||||
Namespace: p.Owner.Login,
|
||||
LastActivityAt: p.UpdatedAt,
|
||||
WebURL: p.HTMLURL,
|
||||
DefaultBranch: p.DefaultBranch,
|
||||
})
|
||||
}
|
||||
if len(projects) < projectsPerPage {
|
||||
break
|
||||
}
|
||||
repos = append(repos, GitLabRepo{
|
||||
Path: p.FullName,
|
||||
Name: p.Name,
|
||||
Namespace: p.Owner.Login,
|
||||
LastActivityAt: p.UpdatedAt,
|
||||
WebURL: p.HTMLURL,
|
||||
DefaultBranch: p.DefaultBranch,
|
||||
})
|
||||
}
|
||||
sort.SliceStable(repos, func(i, j int) bool {
|
||||
return repos[i].LastActivityAt > repos[j].LastActivityAt
|
||||
|
||||
Reference in New Issue
Block a user