From 2d6aadcb46f65b85a993d43cfca73f38dc2c8897 Mon Sep 17 00:00:00 2001 From: ahrav Date: Fri, 14 Oct 2022 09:20:49 -0700 Subject: [PATCH] [THOG-774] - GitHub ignore repo full name (#848) * Use github repo full name. * fix tests. --- pkg/sources/github/github.go | 4 ++-- pkg/sources/github/github_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go index 6a0ff069..f502beb6 100644 --- a/pkg/sources/github/github.go +++ b/pkg/sources/github/github.go @@ -621,7 +621,7 @@ func (s *Source) getReposByOrg(ctx context.Context, org string) ([]string, error s.log.Debugf("Listed repos for org %s page %d/%d", org, opts.Page, res.LastPage) for _, r := range someRepos { - if s.ignoreRepo(r.GetName()) { + if s.ignoreRepo(r.GetFullName()) { continue } @@ -680,7 +680,7 @@ func (s *Source) getReposByUser(ctx context.Context, user string) ([]string, err s.log.Debugf("Listed repos for user %s page %d/%d", user, opts.Page, res.LastPage) for _, r := range someRepos { - if s.ignoreRepo(r.GetName()) { + if s.ignoreRepo(r.GetFullName()) { continue } diff --git a/pkg/sources/github/github_test.go b/pkg/sources/github/github_test.go index a3dc968d..ea0e541c 100644 --- a/pkg/sources/github/github_test.go +++ b/pkg/sources/github/github_test.go @@ -67,11 +67,11 @@ func TestAddReposByOrg(t *testing.T) { Reply(200). JSON([]map[string]string{ {"clone_url": "super-secret-repo", "name": "super-secret-repo"}, - {"clone_url": "super-secret-repo2", "name": "super-secret-repo2"}, + {"clone_url": "super-secret-repo2", "full_name": "secret/super-secret-repo2"}, }) s := initTestSource(nil) - s.ignoreRepos = []string{"super-secret-repo2"} + s.ignoreRepos = []string{"secret/super-secret-repo2"} // gock works here because github.NewClient is using the default HTTP Transport err := s.addRepos(context.TODO(), "super-secret-org", s.getReposByOrg) assert.Nil(t, err) @@ -88,11 +88,11 @@ func TestAddReposByUser(t *testing.T) { Reply(200). JSON([]map[string]string{ {"clone_url": "super-secret-repo", "name": "super-secret-repo"}, - {"clone_url": "super-secret-repo2", "name": "super-secret-repo2"}, + {"clone_url": "super-secret-repo2", "full_name": "secret/super-secret-repo2"}, }) s := initTestSource(nil) - s.ignoreRepos = []string{"super-secret-repo2"} + s.ignoreRepos = []string{"secret/super-secret-repo2"} err := s.addRepos(context.TODO(), "super-secret-user", s.getReposByUser) assert.Nil(t, err) assert.Equal(t, 1, len(s.repos))