Only initiate Gitea client on use
This commit is contained in:
parent
8764edad99
commit
f71f8d1ee0
@ -29,10 +29,12 @@ func (r *GiteaRemote) String() string {
|
||||
// Prepares the Gitea api client
|
||||
func (r *GiteaRemote) setClient() error {
|
||||
var err error
|
||||
r.api, err = gitea.NewClient(r.info.Host,
|
||||
gitea.SetContext(r.info.Context()),
|
||||
gitea.SetToken(r.info.Token),
|
||||
)
|
||||
if r.api == nil {
|
||||
r.api, err = gitea.NewClient(r.info.Host,
|
||||
gitea.SetContext(r.info.Context()),
|
||||
gitea.SetToken(r.info.Token),
|
||||
)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,7 @@ func GetOwnerRepo(fullName string) (string, string) {
|
||||
|
||||
func (r *GiteaRemote) GetNumProjects(opts *remote.RemoteQueryOpts) int {
|
||||
var projects int
|
||||
r.setClient()
|
||||
|
||||
_, resp, err := r.api.SearchRepos(gitea.SearchRepoOptions{ListOptions: gitea.ListOptions{PageSize: 1}})
|
||||
if err != nil {
|
||||
|
@ -13,6 +13,7 @@ const giteaReposPerPage = 20
|
||||
func (r *GiteaRemote) StreamProjects(pi *load.ProgressInfo, opts *remote.RemoteQueryOpts) {
|
||||
defer close(pi.ProgressChan)
|
||||
defer close(pi.ProjectsChan)
|
||||
r.setClient()
|
||||
|
||||
// Get projects. TODO support concurrency
|
||||
giteaListOpts := gitea.ListOptions{Page: 1, PageSize: giteaReposPerPage}
|
||||
|
Loading…
Reference in New Issue
Block a user