From a62270dee53afc03032fa34acc3a352f4c37a0f8 Mon Sep 17 00:00:00 2001 From: Andreas Wachter Date: Mon, 15 Apr 2024 08:09:38 +0200 Subject: [PATCH] debug msgs and check if pushedat is nil (#227) --- bitbucket/bitbucket.go | 1 + gitea/gitea.go | 1 + github/github.go | 4 ++++ gitlab/gitlab.go | 1 + gogs/gogs.go | 1 + onedev/onedev.go | 14 +++++++------- sourcehut/sourcehut.go | 1 + 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bitbucket/bitbucket.go b/bitbucket/bitbucket.go index cef639b..c8d3794 100644 --- a/bitbucket/bitbucket.go +++ b/bitbucket/bitbucket.go @@ -59,6 +59,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { exclude := types.GetMap(repo.Exclude) for _, r := range repositories.Items { + sub.Debug().Msg(r.Links["clone"].([]interface{})[0].(map[string]interface{})["href"].(string)) user := repo.User if r.Owner != nil { if _, ok := r.Owner["nickname"]; ok { diff --git a/gitea/gitea.go b/gitea/gitea.go index 93d24f5..3cc7a2f 100644 --- a/gitea/gitea.go +++ b/gitea/gitea.go @@ -295,6 +295,7 @@ 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(). diff --git a/github/github.go b/github/github.go index 2747eec..adbe903 100644 --- a/github/github.go +++ b/github/github.go @@ -219,6 +219,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { languages := types.GetMap(repo.Filter.Languages) for _, r := range githubrepos { + sub.Debug().Msg(*r.CloneURL) if repo.Filter.ExcludeForks { if *r.Fork { continue @@ -241,6 +242,9 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { if *r.StargazersCount < repo.Filter.Stars { continue } + if r.PushedAt == nil { + continue + } if time.Since(r.PushedAt.Time) > repo.Filter.LastActivityDuration && repo.Filter.LastActivityDuration != 0 { continue } diff --git a/gitlab/gitlab.go b/gitlab/gitlab.go index fd026e2..93d509f 100644 --- a/gitlab/gitlab.go +++ b/gitlab/gitlab.go @@ -203,6 +203,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { } if len(repo.Filter.Languages) > 0 { + sub.Debug().Msg(r.WebURL) langs, _, err := client.Projects.GetProjectLanguages(r.ID) if err != nil { sub.Error(). diff --git a/gogs/gogs.go b/gogs/gogs.go index 7a57ade..fd77898 100644 --- a/gogs/gogs.go +++ b/gogs/gogs.go @@ -172,6 +172,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { excludeorgs := types.GetMap(repo.ExcludeOrgs) for _, r := range gogsrepos { + sub.Debug().Msg(r.HTMLURL) if repo.Filter.ExcludeForks { if r.Fork { continue diff --git a/onedev/onedev.go b/onedev/onedev.go index f718b12..3ebbd25 100644 --- a/onedev/onedev.go +++ b/onedev/onedev.go @@ -84,6 +84,13 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { } for _, r := range userrepos { + urls, _, err := client.GetCloneUrl(r.ID) + if err != nil { + sub.Error(). + Msg("couldn't get clone urls") + continue + } + sub.Debug().Msg(urls.HTTP) if repo.Filter.ExcludeForks { if r.ForkedFromID != 0 { continue @@ -98,13 +105,6 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { } } - urls, _, err := client.GetCloneUrl(r.ID) - if err != nil { - sub.Error(). - Msg("couldn't get clone urls") - continue - } - defaultbranch, _, err := client.GetDefaultBranch(r.ID) if err != nil { sub.Error(). diff --git a/sourcehut/sourcehut.go b/sourcehut/sourcehut.go index d99cdbf..1e8a1d3 100644 --- a/sourcehut/sourcehut.go +++ b/sourcehut/sourcehut.go @@ -203,6 +203,7 @@ func Get(conf *types.Conf) ([]types.Repo, bool) { for _, r := range repositories.Results { repoURL := fmt.Sprintf("%s%s/%s", repo.URL, repo.User, r.Name) sshURL := fmt.Sprintf("git@%s:%s/%s", types.GetHost(repo.URL), r.Owner.CanonicalName, r.Name) + sub.Debug().Msg(repoURL) refs, err := getRefs(apiURL, r.Name, token) if err != nil {