8
8
9
9
namespace Nullinside . Cicd . GitHub . Rule ;
10
10
11
+ /// <summary>
12
+ /// Creates the branch merging rules based on the code bases' language.
13
+ /// </summary>
11
14
public class CreateRulesets : IRepoRule {
15
+ /// <inheritdoc />
12
16
public async Task Handle ( GitHubClient client , Connection graphQl , ID projectId , Repository repo ) {
13
17
// This currently doesn't run properly. You get an error about not specifying multiple Parameters on the status
14
18
// 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,
18
22
. Rulesets ( )
19
23
. AllPages ( )
20
24
. Select ( i => i . Name ) ) ;
21
-
25
+
22
26
string ? expectedRuleset =
23
27
rulesets . FirstOrDefault ( r => "main" . Equals ( r , StringComparison . InvariantCultureIgnoreCase ) ) ;
24
28
if ( null != expectedRuleset ) {
25
29
return ;
26
30
}
27
-
31
+
28
32
ID id = await graphQl . Run ( new Query ( )
29
33
. Repository ( repo . Name , Constants . GITHUB_ORG )
30
34
. Select ( i => i . Id ) ) ;
31
-
35
+
32
36
Console . WriteLine ( $ "{ repo . Name } : Creating default ruleset") ;
33
- StatusCheckConfigurationInput [ ] statusChecks = null ;
37
+ StatusCheckConfigurationInput [ ] ? statusChecks = null ;
34
38
if ( "Typescript" . Equals ( repo . Language , StringComparison . InvariantCultureIgnoreCase ) ) {
35
39
statusChecks = new [ ] {
36
40
new StatusCheckConfigurationInput {
@@ -90,7 +94,7 @@ public async Task Handle(GitHubClient client, Connection graphQl, ID projectId,
90
94
}
91
95
} ) ;
92
96
}
93
-
97
+
94
98
await graphQl . Run ( new Mutation ( )
95
99
. CreateRepositoryRuleset ( new Arg < CreateRepositoryRulesetInput > ( new CreateRepositoryRulesetInput {
96
100
SourceId = id ,
0 commit comments