package gitearemote import ( "fmt" "strconv" "strings" "code.gitea.io/sdk/gitea" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/remote" ) func (r *GiteaRemote) ReposToProjects(repos []*gitea.Repository) []*projects.Project { pList := make([]*projects.Project, len(repos)) for i, repo := range repos { path := strings.Split(repo.FullName, "/") project := &projects.Project{ ID: int(repo.ID), Description: repo.Description, SSHURLToRepo: repo.SSHURL, HTTPURLToRepo: repo.CloneURL, WebURL: repo.HTMLURL, Name: repo.Name, NameWithNamespace: repo.FullName, Path: path[len(path)-1], AvatarURL: repo.AvatarURL, PathWithNamespace: strings.Join(path, "/"), LastActivityAt: repo.Updated, Remote: r.info.Host, } pList[i] = project } return pList } 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) return -1 } projects, _ = strconv.Atoi(resp.Header.Get("X-Total-Count")) return projects }