Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit 1037701

Browse files
Add additional checks to configuration and improve config file handling
1 parent b49da78 commit 1037701

3 files changed

Lines changed: 28 additions & 16 deletions

File tree

RepositoryLinter/GlobalConfiguration.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ public class GlobalConfiguration
2929

3030
public List<CheckerConfiguration> Checks { get; set; } = new();
3131

32+
public bool IsFromConfigFile { get; set; }
33+
3234
public static GlobalConfiguration ReadConfiguration(string path)
3335
{
36+
Console.WriteLine("Reading configuration file");
3437
var deserializer = new DeserializerBuilder()
3538
.IgnoreUnmatchedProperties()
3639
.Build();
3740
var yaml = File.ReadAllText(path);
3841
var config = deserializer.Deserialize<GlobalConfiguration>(yaml);
42+
config.IsFromConfigFile = true;
3943

4044
return config;
4145
}

RepositoryLinter/Program.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
rootCommand.AddOption(configOption);
3636

3737
// Create global config
38-
var config = new GlobalConfiguration();
38+
var config = GlobalConfiguration.ReadConfiguration("/app/config.yaml");
39+
3940

4041
var commandLineBuilder = new CommandLineBuilder(rootCommand);
4142

@@ -45,25 +46,13 @@
4546
var tokens = context.ParseResult.Tokens;
4647
var args = tokens.Select(t => t.Value).ToArray();
4748

48-
// Set global options
49-
config.GitIgnoreEnabled = !args.Contains("--ignore-gitignore");
50-
config.TruncateOutput = !args.Contains("--disable-truncate");
51-
config.CleanUp = !args.Contains("--disable-cleanup");
52-
53-
// Set path to save to
54-
if (context.ParseResult.HasOption(pathToSaveOption))
55-
{
56-
config.PathToSaveGitRepos = context.ParseResult.GetValueForOption(pathToSaveOption)!;
57-
}
58-
59-
// Handle config file
6049
if (context.ParseResult.HasOption(configOption))
6150
{
6251
try
6352
{
6453
var configFile = context.ParseResult.GetValueForOption(configOption)!;
6554
var newConfig = GlobalConfiguration.ReadConfiguration(configFile.FullName);
66-
if (newConfig != null)
55+
if (newConfig.IsFromConfigFile)
6756
{
6857
config = newConfig;
6958
}
@@ -75,6 +64,17 @@
7564
}
7665
}
7766

67+
// Set global options
68+
config.GitIgnoreEnabled = !args.Contains("--ignore-gitignore");
69+
config.TruncateOutput = !args.Contains("--disable-truncate");
70+
config.CleanUp = !args.Contains("--disable-cleanup");
71+
72+
// Set path to save to
73+
if (context.ParseResult.HasOption(pathToSaveOption))
74+
{
75+
config.PathToSaveGitRepos = context.ParseResult.GetValueForOption(pathToSaveOption)!;
76+
}
77+
7878
await next(context);
7979
});
8080

RepositoryLinter/config.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Checks:
22
- Name: "License Exists"
33
AllowedToFail: true
4-
5-
PathToSaveGitRepos: "~/RepositoryLinter/git_repos"
4+
- Name: ".gitignore exists"
5+
AllowedToFail: true
6+
- Name: "README exists"
7+
AllowedToFail: true
8+
- Name: "GitHub Workdflow exists"
9+
AllowedToFail: true
10+
- Name: "Secrets check"
11+
AllowedToFail: true
12+
- Name: "Tests exists"
13+
AllowedToFail: true

0 commit comments

Comments
 (0)