Skip to content

Commit

Permalink
Using a new API to fetch both public and private repos of a user (#671)
Browse files Browse the repository at this point in the history
Co-authored-by: rick <[email protected]>
  • Loading branch information
ks-ci-bot and LinuxSuRen authored Jun 14, 2022
1 parent 5872afa commit b3032ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/kapis/devops/v1alpha3/scm/scmhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func (h *handler) getRepositories(scm, server, org, secret, namespace string, pa
var listRepositoryFunc listRepository
if user, err = h.getCurrentUsername(c); err == nil {
if user == org && !strings.HasPrefix(scm, "bitbucket") {
listRepositoryFunc = c.Repositories.ListUser
listRepositoryFunc = func(ctx context.Context, s string, options goscm.ListOptions) ([]*goscm.Repository, *goscm.Response, error) {
return c.Repositories.List(ctx, options)
}
} else {
listRepositoryFunc = c.Repositories.ListOrganisation
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/kapis/devops/v1alpha3/scm/scmhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ func TestSCMAPI(t *testing.T) {
}

gock.New("https://api.github.com").
Get("users/octocat/repos").
Get("/user/repos").
MatchParam("per_page", "1").
MatchParam("page", "1").
MatchParam("visibility", "all").
MatchParam("affiliation", "owner").
Reply(200).
Type("application/json").
SetHeaders(mockHeaders).
Expand Down

0 comments on commit b3032ae

Please sign in to comment.