@@ -53,7 +53,7 @@ public async Task ValidateCreateRepository(IssuesEvent issuesEvent, bool createP
5353 // Validate if the teams exist
5454 var teamsString = $ "{ repoRequest . RepositoryMaintainers } ,{ repoRequest . RepositoryContributors } ,{ repoRequest . RepositoryReaders } ";
5555
56- var teams = teamsString . Split ( Constants . Comma , StringSplitOptions . RemoveEmptyEntries ) ;
56+ var teams = teamsString . Split ( Constants . Comma , StringSplitOptions . RemoveEmptyEntries ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
5757
5858 foreach ( var team in teams )
5959 {
@@ -298,7 +298,8 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
298298 // Step 2: Add the reader teams to the repo
299299 if ( repoRequest . RepositoryReaders != null )
300300 {
301- var teams = repoRequest . RepositoryReaders . Split ( Constants . Comma ) ;
301+ var teams = repoRequest . RepositoryReaders . Split ( Constants . Comma ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
302+
302303 foreach ( var team in teams )
303304 {
304305 await installationClient . Organization . Team . AddOrUpdateTeamRepositoryPermissions ( repoRequest . RepositoryOwner , team , repoRequest . RepositoryOwner , repoRequest . RepositoryName , CollaboratorPermission . Pull . ToString ( ) . ToLowerInvariant ( ) ) ;
@@ -308,7 +309,7 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
308309 // Step 3: Add the contributor teams to the repo
309310 if ( repoRequest . RepositoryContributors != null )
310311 {
311- var teams = repoRequest . RepositoryContributors . Split ( Constants . Comma ) ;
312+ var teams = repoRequest . RepositoryContributors . Split ( Constants . Comma ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
312313 foreach ( var team in teams )
313314 {
314315 await installationClient . Organization . Team . AddOrUpdateTeamRepositoryPermissions ( repoRequest . RepositoryOwner , team , repoRequest . RepositoryOwner , repoRequest . RepositoryName , CollaboratorPermission . Push . ToString ( ) . ToLowerInvariant ( ) ) ;
@@ -318,7 +319,7 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
318319 // Step 4: Add the maintain teams to the repo
319320 if ( repoRequest . RepositoryMaintainers != null )
320321 {
321- var teams = repoRequest . RepositoryMaintainers . Split ( Constants . Comma ) ;
322+ var teams = repoRequest . RepositoryMaintainers . Split ( Constants . Comma ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
322323 foreach ( var team in teams )
323324 {
324325 await installationClient . Organization . Team . AddOrUpdateTeamRepositoryPermissions ( repoRequest . RepositoryOwner , team , repoRequest . RepositoryOwner , repoRequest . RepositoryName , CollaboratorPermission . Maintain . ToString ( ) . ToLowerInvariant ( ) ) ;
0 commit comments