@@ -17,11 +17,26 @@ func GetAllRepositoriesCollaborators(ctx context.Context, githubClient model.Git
1717 repositoryName = value .(string )
1818 }
1919
20+ teamsRepositories , err := GetAllTeamsRepositories (ctx , githubClient , organizationName , stream )
21+ if err != nil {
22+ return nil , err
23+ }
24+
2025 if repositoryName != "" {
21- repoValues , err := GetRepositoryCollaborators (ctx , githubClient , stream , organizationName , repositoryName )
26+ org , err := GetOrganizationAdditionalData (ctx , githubClient .RestClient , organizationName )
27+ var orgId int64
28+ if org != nil && org .ID != nil {
29+ orgId = * org .ID
30+ }
31+ repoValues , err := GetRepositoryCollaborators (ctx , githubClient , stream , organizationName , orgId , repositoryName )
2232 if err != nil {
2333 return nil , err
2434 }
35+ for _ , t := range teamsRepositories {
36+ if t .Description .(model.RepoCollaboratorsDescription ).RepositoryName == repositoryName {
37+ repoValues = append (repoValues , t )
38+ }
39+ }
2540 return repoValues , nil
2641 }
2742 repositories , err := getRepositories (ctx , client , organizationName )
@@ -30,16 +45,22 @@ func GetAllRepositoriesCollaborators(ctx context.Context, githubClient model.Git
3045 }
3146 var values []models.Resource
3247 for _ , repo := range repositories {
33- repoValues , err := GetRepositoryCollaborators (ctx , githubClient , stream , organizationName , repo .GetName ())
48+ org , err := GetOrganizationAdditionalData (ctx , githubClient .RestClient , organizationName )
49+ var orgId int64
50+ if org != nil && org .ID != nil {
51+ orgId = * org .ID
52+ }
53+ repoValues , err := GetRepositoryCollaborators (ctx , githubClient , stream , organizationName , orgId , repo .GetName ())
3454 if err != nil {
3555 return nil , err
3656 }
3757 values = append (values , repoValues ... )
3858 }
59+ values = append (values , teamsRepositories ... )
3960 return values , nil
4061}
4162
42- func GetRepositoryCollaborators (ctx context.Context , githubClient model.GitHubClient , stream * models.StreamSender , owner , repo string ) ([]models.Resource , error ) {
63+ func GetRepositoryCollaborators (ctx context.Context , githubClient model.GitHubClient , stream * models.StreamSender , owner string , orgId int64 , repo string ) ([]models.Resource , error ) {
4364 client := githubClient .GraphQLClient
4465 affiliation := githubv4 .CollaboratorAffiliationAll
4566 var query struct {
@@ -76,12 +97,13 @@ func GetRepositoryCollaborators(ctx context.Context, githubClient model.GitHubCl
7697 ID : id ,
7798 Name : collaborator .Node .Name ,
7899 Description : model.RepoCollaboratorsDescription {
79- Affiliation : "ALL" ,
80- RepoFullName : repoFullName ,
81- Permission : collaborator .Permission ,
82- UserLogin : collaborator .Node .Login ,
83- Organization : owner ,
84- RepositoryName : repo ,
100+ RepositoryName : repo ,
101+ RepoFullName : repoFullName ,
102+ CollaboratorID : collaborator .Node .Login ,
103+ CollaboratorType : "User" ,
104+ Permission : collaborator .Permission ,
105+ Organization : owner ,
106+ OrganizationID : orgId ,
85107 },
86108 }
87109 if stream != nil {
0 commit comments