1
1
mirror of https://github.com/cooperspencer/gickup synced 2024-11-08 12:09:18 +01:00
* get user from gitea

* better output

* gogs use "token user"
This commit is contained in:
Andreas Wachter 2023-02-07 06:56:51 +01:00 committed by GitHub
parent 9d4a2cd3cc
commit 7bffb8d992
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 15 deletions

@ -160,10 +160,17 @@ func Get(conf *types.Conf) []types.Repo {
if repo.URL == "" {
repo.URL = "https://gitea.com"
}
log.Info().
Str("stage", "gitea").
Str("url", repo.URL).
Msgf("grabbing repositories from %s", repo.User)
if repo.User == "" {
log.Info().
Str("stage", "gitea").
Str("url", repo.URL).
Msg("grabbing my repositories")
} else {
log.Info().
Str("stage", "gitea").
Str("url", repo.URL).
Msgf("grabbing repositories from %s", repo.User)
}
opt := gitea.ListReposOptions{}
opt.PageSize = 50
opt.Page = 1
@ -178,13 +185,25 @@ func Get(conf *types.Conf) []types.Repo {
client, err = gitea.NewClient(repo.URL)
}
for {
if token != "" && repo.User == "" {
user, _, err := client.GetMyUserInfo()
if err != nil {
log.Fatal().
Str("stage", "gitea").
Str("url", repo.URL).
Msg(err.Error())
}
repo.User = user.UserName
}
if err != nil {
log.Fatal().
Str("stage", "gitea").
Str("url", repo.URL).
Msg(err.Error())
}
for {
repos, _, err := client.ListUserRepos(repo.User, opt)
if err != nil {
log.Fatal().

@ -31,10 +31,17 @@ func addWiki(r github.Repository, repo types.GenRepo, token string) types.Repo {
func Get(conf *types.Conf) []types.Repo {
repos := []types.Repo{}
for _, repo := range conf.Source.Github {
log.Info().
Str("stage", "github").
Str("url", "https://github.com").
Msgf("grabbing the repositories from %s", repo.User)
if repo.User == "" {
log.Info().
Str("stage", "github").
Str("url", "https://github.com").
Msg("grabbing my repositories")
} else {
log.Info().
Str("stage", "github").
Str("url", "https://github.com").
Msgf("grabbing the repositories from %s", repo.User)
}
opt := &github.RepositoryListOptions{
ListOptions: github.ListOptions{

@ -126,14 +126,28 @@ func Backup(r types.Repo, d types.GenRepo, dry bool) {
func Get(conf *types.Conf) []types.Repo {
repos := []types.Repo{}
for _, repo := range conf.Source.Gogs {
log.Info().
Str("stage", "gogs").
Str("url", repo.URL).
Msgf("grabbing repositories from %s", repo.User)
if repo.User == "" {
log.Info().
Str("stage", "gogs").
Str("url", repo.URL).
Msg("grabbing my repositories")
} else {
log.Info().
Str("stage", "gogs").
Str("url", repo.URL).
Msgf("grabbing repositories from %s", repo.User)
}
token := repo.GetToken()
client := gogs.NewClient(repo.URL, token)
gogsrepos, err := client.ListUserRepos(repo.User)
var gogsrepos []*gogs.Repository
var err error
if repo.User == "" {
gogsrepos, err = client.ListMyRepos()
} else {
gogsrepos, err = client.ListUserRepos(repo.User)
}
if err != nil {
log.Fatal().
Str("stage", "gogs").
@ -203,7 +217,14 @@ func Get(conf *types.Conf) []types.Repo {
}
}
}
orgs, err := client.ListUserOrgs(repo.User)
var orgs []*gogs.Organization
if repo.User == "" {
orgs, err = client.ListMyOrgs()
} else {
orgs, err = client.ListUserOrgs(repo.User)
}
if err != nil {
log.Fatal().
Str("stage", "gogs").