@@ -53,9 +53,9 @@ 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 ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
56+ var teams = teamsString . ConvertCsvToList ( ) ;
5757
58- foreach ( var team in teams )
58+ foreach ( var team in teams ! )
5959 {
6060 // Check if the team is valid
6161 try
@@ -83,9 +83,9 @@ public async Task ValidateCreateRepository(IssuesEvent issuesEvent, bool createP
8383 if ( repoRequest . RepositoryRulesets != null )
8484 {
8585 // Check if the rulesets exist as values of the custom property
86- var rulesets = repoRequest . RepositoryRulesets . Split ( Constants . Comma , StringSplitOptions . RemoveEmptyEntries ) . Select ( i => i . Trim ( ) ) ;
86+ var rulesets = repoRequest . RepositoryRulesets . ConvertCsvToList ( ) ;
8787
88- foreach ( var ruleset in rulesets )
88+ foreach ( var ruleset in rulesets ! )
8989 {
9090 // Check if the custom property has valid values
9191 try
@@ -142,12 +142,12 @@ public async Task ValidateCreateRepository(IssuesEvent issuesEvent, bool createP
142142
143143 if ( isValid )
144144 {
145- validationMessage = $ "{ _localizationService . GetLocalizedString ( Constants . ISSUE_VALIDATED ) } \n { string . Join ( "\n - " , validationReasons ) } ";
145+ validationMessage = $ "{ _localizationService . GetLocalizedString ( Constants . ISSUE_VALIDATED ) } \n - { string . Join ( "\n - " , validationReasons ) } ";
146146 await _issueService . ChangeIssueLabel ( [ TicketStatus . VALIDATED . ToString ( ) ] , issuesEvent ! ) ;
147147 }
148148 else
149149 {
150- validationMessage = $ "{ _localizationService . GetLocalizedString ( Constants . ISSUE_FAILED ) } \n { string . Join ( "\n - " , validationReasons ) } ";
150+ validationMessage = $ "{ _localizationService . GetLocalizedString ( Constants . ISSUE_FAILED ) } \n - { string . Join ( "\n - " , validationReasons ) } ";
151151 await _issueService . ChangeIssueLabel ( [ TicketStatus . FAILED . ToString ( ) ] , issuesEvent ! ) ;
152152 }
153153
@@ -298,9 +298,9 @@ 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 ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
301+ var teams = repoRequest . RepositoryReaders . ConvertCsvToList ( ) ;
302302
303- foreach ( var team in teams )
303+ foreach ( var team in teams ! )
304304 {
305305 await installationClient . Organization . Team . AddOrUpdateTeamRepositoryPermissions ( repoRequest . RepositoryOwner , team , repoRequest . RepositoryOwner , repoRequest . RepositoryName , CollaboratorPermission . Pull . ToString ( ) . ToLowerInvariant ( ) ) ;
306306 }
@@ -309,8 +309,8 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
309309 // Step 3: Add the contributor teams to the repo
310310 if ( repoRequest . RepositoryContributors != null )
311311 {
312- var teams = repoRequest . RepositoryContributors . Split ( Constants . Comma ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
313- foreach ( var team in teams )
312+ var teams = repoRequest . RepositoryContributors . ConvertCsvToList ( ) ;
313+ foreach ( var team in teams ! )
314314 {
315315 await installationClient . Organization . Team . AddOrUpdateTeamRepositoryPermissions ( repoRequest . RepositoryOwner , team , repoRequest . RepositoryOwner , repoRequest . RepositoryName , CollaboratorPermission . Push . ToString ( ) . ToLowerInvariant ( ) ) ;
316316 }
@@ -319,8 +319,8 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
319319 // Step 4: Add the maintain teams to the repo
320320 if ( repoRequest . RepositoryMaintainers != null )
321321 {
322- var teams = repoRequest . RepositoryMaintainers . Split ( Constants . Comma ) . Select ( i => i . Trim ( ) ) . Distinct ( ) ;
323- foreach ( var team in teams )
322+ var teams = repoRequest . RepositoryMaintainers . ConvertCsvToList ( ) ;
323+ foreach ( var team in teams ! )
324324 {
325325 await installationClient . Organization . Team . AddOrUpdateTeamRepositoryPermissions ( repoRequest . RepositoryOwner , team , repoRequest . RepositoryOwner , repoRequest . RepositoryName , CollaboratorPermission . Maintain . ToString ( ) . ToLowerInvariant ( ) ) ;
326326 }
@@ -334,7 +334,7 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
334334 // Add the repo branch protection rulesets based on the custom properties
335335 if ( repoRequest . RepositoryRulesets != null )
336336 {
337- var rulesets = repoRequest . RepositoryRulesets . Split ( Constants . Comma , StringSplitOptions . RemoveEmptyEntries ) . Select ( i => i . Trim ( ) ) . ToList ( ) ;
337+ var rulesets = repoRequest . RepositoryRulesets . ConvertCsvToList ( ) ;
338338
339339 await installationClient . Repository . CustomProperty . CreateOrUpdate ( repoRequest . RepositoryOwner , repoRequest . RepositoryName , new UpsertRepositoryCustomPropertyValues ( )
340340 {
@@ -395,7 +395,7 @@ public async Task SaveRepository(PullRequestEvent pullRequestEvent)
395395 {
396396 // Raise the PR to the inventory repo
397397 var prTitle = $ "{ repoRequest . RequestType } - { repoRequest . RepositoryName } - { Constants . GitHubPullRequestTitleIssueNumber } { repoRequest . RequestIssue } ";
398- var prBody = $ "{ _localizationService . GetLocalizedString ( Constants . PULL_REQUEST_BODY ) } \n \n - Issue Request: { repoRequest . RequestIssueHtmlUrl } \n \n { repoRequestYaml } ";
398+ var prBody = $ "{ _localizationService . GetLocalizedString ( Constants . PULL_REQUEST_BODY ) } \n \n - Issue Request: { repoRequest . RequestIssueHtmlUrl } \n \n ```yaml \n { repoRequestYaml } \n ``` ";
399399
400400 var pr = await gitHubClient . CreatePullRequestAsync (
401401 repoRequest . RepositoryOwner ! ,
0 commit comments