Gitea remote support

This commit is contained in:
Ryan McGuire 2024-01-16 14:32:12 -05:00
parent 94bbff6d07
commit 9747261a76
2 changed files with 12 additions and 4 deletions

View File

@ -57,6 +57,11 @@ cache:
``` ```
## TODO ## 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] Use multi-gitlab by default in config init
- [x] Update docs for multi-gitlab - [x] Update docs for multi-gitlab
- [x] Remove all references to old keys - [x] Remove all references to old keys

View File

@ -14,6 +14,7 @@ const giteaReposPerPage = 20
func (r *GiteaRemote) GetNumProjects(opts *remote.RemoteQueryOpts) int { func (r *GiteaRemote) GetNumProjects(opts *remote.RemoteQueryOpts) int {
var projects int var projects int
_, resp, err := r.api.SearchRepos(gitea.SearchRepoOptions{ListOptions: gitea.ListOptions{PageSize: 1}}) _, resp, err := r.api.SearchRepos(gitea.SearchRepoOptions{ListOptions: gitea.ListOptions{PageSize: 1}})
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
@ -30,7 +31,6 @@ func (r *GiteaRemote) StreamProjects(pi *load.ProgressInfo, opts *remote.RemoteQ
// Get projects. TODO support concurrency // Get projects. TODO support concurrency
giteaListOpts := gitea.ListOptions{Page: 1, PageSize: giteaReposPerPage} giteaListOpts := gitea.ListOptions{Page: 1, PageSize: giteaReposPerPage}
for { for {
repos, resp, err := r.api.ListMyRepos(gitea.ListReposOptions{ListOptions: giteaListOpts}) 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 { if err != nil {
pi.ErrorChan <- err pi.ErrorChan <- err
break break
} else if resp.NextPage == resp.PrevPage {
break
} else if len(repos) < 1 { } else if len(repos) < 1 {
pi.ErrorChan <- errors.New("No gitea repos found") pi.ErrorChan <- errors.New("No gitea repos found")
break break
} }
// TODO finish implementing project load support
for _, repo := range repos { for _, repo := range repos {
fmt.Println(repo) fmt.Printf("Repo: %#v\n", repo)
}
if resp.LastPage == resp.NextPage {
break
} }
giteaListOpts.Page = resp.NextPage giteaListOpts.Page = resp.NextPage