Skip to content

Commit

Permalink
fix gitlab and better debug outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperspencer committed Aug 28, 2024
1 parent 4bf2cea commit 345a5f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion gitea/gitea.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
languages := types.GetMap(repo.Filter.Languages)

for _, r := range gitearepos {
sub.Debug().Str("repo-type", "user").Msg(r.HTMLURL)
if repo.Filter.ExcludeForks {
if r.Fork {
continue
Expand All @@ -296,7 +297,6 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}

if len(repo.Filter.Languages) > 0 {
sub.Debug().Msg(r.HTMLURL)
langs, _, err := client.GetRepoLanguages(r.Owner.UserName, r.Name)
if err != nil {
sub.Error().
Expand Down Expand Up @@ -430,6 +430,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
}
}
for _, r := range orgrepos {
sub.Debug().Str("repo-type", "org").Msg(r.HTMLURL)
if repo.Filter.ExcludeForks {
if r.Fork {
continue
Expand Down
10 changes: 9 additions & 1 deletion gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
continue
}

userNotInConfig := false

if repo.User == "" {
user, _, err := client.Users.CurrentUser()
if err != nil {
Expand All @@ -130,6 +132,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
continue
}
repo.User = user.Username
userNotInConfig = true
}

sub.Info().
Expand All @@ -151,7 +154,12 @@ func Get(conf *types.Conf) ([]types.Repo, bool) {
i := 1
for {
opt.Page = i
projects, _, err := client.Projects.ListProjects(opt)
projects := []*gitlab.Project{}
if userNotInConfig {
projects, _, err = client.Projects.ListProjects(opt)
} else {
projects, _, err = client.Projects.ListUserProjects(user.ID, opt)
}
if err != nil {
sub.Error().
Msg(err.Error())
Expand Down

0 comments on commit 345a5f0

Please sign in to comment.