From 9747261a767ed73c84f4ac4f71a01a01069db8e0 Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Tue, 16 Jan 2024 14:32:12 -0500 Subject: [PATCH] Gitea remote support --- README.md | 5 +++++ internal/remotes/gitea/gitea_api.go | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42dc851..5bbe657 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,11 @@ cache: ``` ## TODO +- [ ] Make generic, this is any git remote, not just GitLab + - [ ] Add Gitea support + - [ ] Add GitHub support + - [ ] Rename --gitlab flag to --remote +- [ ] Add option to select individual remote for `gpm cache load` - [x] Use multi-gitlab by default in config init - [x] Update docs for multi-gitlab - [x] Remove all references to old keys diff --git a/internal/remotes/gitea/gitea_api.go b/internal/remotes/gitea/gitea_api.go index 8956c02..c9fbf0b 100644 --- a/internal/remotes/gitea/gitea_api.go +++ b/internal/remotes/gitea/gitea_api.go @@ -14,6 +14,7 @@ const giteaReposPerPage = 20 func (r *GiteaRemote) GetNumProjects(opts *remote.RemoteQueryOpts) int { var projects int + _, resp, err := r.api.SearchRepos(gitea.SearchRepoOptions{ListOptions: gitea.ListOptions{PageSize: 1}}) if err != nil { fmt.Println(err) @@ -30,7 +31,6 @@ func (r *GiteaRemote) StreamProjects(pi *load.ProgressInfo, opts *remote.RemoteQ // Get projects. TODO support concurrency giteaListOpts := gitea.ListOptions{Page: 1, PageSize: giteaReposPerPage} - for { repos, resp, err := r.api.ListMyRepos(gitea.ListReposOptions{ListOptions: giteaListOpts}) @@ -39,15 +39,18 @@ func (r *GiteaRemote) StreamProjects(pi *load.ProgressInfo, opts *remote.RemoteQ if err != nil { pi.ErrorChan <- err break - } else if resp.NextPage == resp.PrevPage { - break } else if len(repos) < 1 { pi.ErrorChan <- errors.New("No gitea repos found") break } + // TODO finish implementing project load support for _, repo := range repos { - fmt.Println(repo) + fmt.Printf("Repo: %#v\n", repo) + } + + if resp.LastPage == resp.NextPage { + break } giteaListOpts.Page = resp.NextPage