File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace Gttsb . Core
22{
3- public sealed class SyncInput
3+ public sealed record SyncInput
44 {
55 public IEnumerable < string > GitHubTeamNames { get ; init ; } = Enumerable . Empty < string > ( ) ;
66 public string EmailAppend { get ; init ; } = String . Empty ;
Original file line number Diff line number Diff line change 11using Gttsb . Core ;
2+ using Newtonsoft . Json ;
23using Octokit ;
34using Octokit . GraphQL ;
45using YamlDotNet . Serialization ;
@@ -163,9 +164,27 @@ public async Task<SyncInput> GetConfigurationForInstallationAsync()
163164 var configurationAsString = System . Text . Encoding . Default . GetString ( configurationContent ) ;
164165
165166 var deserializer = new DeserializerBuilder ( ) . Build ( ) ;
166- var yamlObject = deserializer . Deserialize < SyncInput > ( configurationAsString ) ;
167167
168- return yamlObject ;
168+ // TODO: fix this nonsense
169+ // https://github.com/aaubry/YamlDotNet/issues/571
170+ var rawYamlObject = deserializer . Deserialize < object > ( configurationAsString ) ;
171+ var syncInput = JsonConvert . DeserializeObject < SyncInput > ( JsonConvert . SerializeObject ( rawYamlObject ) ) ;
172+
173+ if ( syncInput == null )
174+ {
175+ // TODO: throw proper custom exception
176+ throw new Exception ( "Configuration appears to be null" ) ;
177+ }
178+
179+ // One could argue that such logic is too many responsibilities for this method. I pose this is a fine tradeoff though...
180+ // Once we get around to implementing config file status checks, I will most likely change my mind.
181+ // This could also be turned into a Set.
182+ syncInput = syncInput with
183+ {
184+ GitHubTeamNames = syncInput . GitHubTeamNames . Distinct ( ) . ToList ( )
185+ } ;
186+
187+ return syncInput ;
169188 }
170189 }
171190}
You can’t perform that action at this time.
0 commit comments