88
99namespace Nullinside . Cicd . GitHub . Rule ;
1010
11+ /// <summary>
12+ /// Creates the branch merging rules based on the code bases' language.
13+ /// </summary>
1114public class CreateRulesets : IRepoRule {
15+ /// <inheritdoc />
1216 public async Task Handle ( GitHubClient client , Connection graphQl , ID projectId , Repository repo ) {
1317 // This currently doesn't run properly. You get an error about not specifying multiple Parameters on the status
1418 // checks. Waiting on an update from the source library to not include nulls in the compiled query.
@@ -18,19 +22,19 @@ public async Task Handle(GitHubClient client, Connection graphQl, ID projectId,
1822 . Rulesets ( )
1923 . AllPages ( )
2024 . Select ( i => i . Name ) ) ;
21-
25+
2226 string ? expectedRuleset =
2327 rulesets . FirstOrDefault ( r => "main" . Equals ( r , StringComparison . InvariantCultureIgnoreCase ) ) ;
2428 if ( null != expectedRuleset ) {
2529 return ;
2630 }
27-
31+
2832 ID id = await graphQl . Run ( new Query ( )
2933 . Repository ( repo . Name , Constants . GITHUB_ORG )
3034 . Select ( i => i . Id ) ) ;
31-
35+
3236 Console . WriteLine ( $ "{ repo . Name } : Creating default ruleset") ;
33- StatusCheckConfigurationInput [ ] statusChecks = null ;
37+ StatusCheckConfigurationInput [ ] ? statusChecks = null ;
3438 if ( "Typescript" . Equals ( repo . Language , StringComparison . InvariantCultureIgnoreCase ) ) {
3539 statusChecks = new [ ] {
3640 new StatusCheckConfigurationInput {
@@ -90,7 +94,7 @@ public async Task Handle(GitHubClient client, Connection graphQl, ID projectId,
9094 }
9195 } ) ;
9296 }
93-
97+
9498 await graphQl . Run ( new Mutation ( )
9599 . CreateRepositoryRuleset ( new Arg < CreateRepositoryRulesetInput > ( new CreateRepositoryRulesetInput {
96100 SourceId = id ,
0 commit comments