Skip to content

Commit 2661715

Browse files
Copilotarturcic
andcommitted
Fix build errors: remove trailing whitespace, suppress obsolete warnings, and fix null reference issues
Co-authored-by: arturcic <[email protected]>
1 parent 22e86b0 commit 2661715

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

src/GitVersion.App/ArgumentInterceptor.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private void ValidateAndProcessArguments(Arguments arguments)
8080
// Process assembly info files
8181
if (!arguments.EnsureAssemblyInfo)
8282
{
83-
arguments.UpdateAssemblyInfoFileName = ResolveFiles(arguments.TargetPath, arguments.UpdateAssemblyInfoFileName).ToHashSet();
83+
arguments.UpdateAssemblyInfoFileName = ResolveFiles(arguments.TargetPath ?? SysEnv.CurrentDirectory, arguments.UpdateAssemblyInfoFileName).ToHashSet();
8484
}
8585
}
8686

@@ -134,41 +134,41 @@ private static Arguments ConvertToArguments(GitVersionSettings settings)
134134
var arguments = new Arguments();
135135

136136
// Set target path - prioritize explicit targetpath option over positional argument
137-
arguments.TargetPath = settings.TargetPathOption?.TrimEnd('/', '\\')
138-
?? settings.TargetPath?.TrimEnd('/', '\\')
137+
arguments.TargetPath = settings.TargetPathOption?.TrimEnd('/', '\\')
138+
?? settings.TargetPath?.TrimEnd('/', '\\')
139139
?? SysEnv.CurrentDirectory;
140140

141141
// Configuration options
142142
arguments.ConfigurationFile = settings.ConfigurationFile;
143143
arguments.ShowConfiguration = settings.ShowConfiguration;
144-
144+
145145
// Handle override configuration
146146
if (settings.OverrideConfiguration != null && settings.OverrideConfiguration.Any())
147147
{
148148
var parser = new OverrideConfigurationOptionParser();
149-
149+
150150
foreach (var kvp in settings.OverrideConfiguration)
151151
{
152152
// Validate the key format - Spectre.Console.Cli should have already parsed key=value correctly
153153
// but we still need to validate against supported properties
154154
var keyValueOption = $"{kvp.Key}={kvp.Value}";
155-
155+
156156
var optionKey = kvp.Key.ToLowerInvariant();
157157
if (!OverrideConfigurationOptionParser.SupportedProperties.Contains(optionKey))
158158
{
159159
throw new WarningException($"Could not parse --override-config option: {keyValueOption}. Unsupported 'key'.");
160160
}
161-
161+
162162
parser.SetValue(optionKey, kvp.Value);
163163
}
164-
164+
165165
arguments.OverrideConfiguration = parser.GetOverrideConfiguration();
166166
}
167167
else
168168
{
169169
arguments.OverrideConfiguration = new Dictionary<object, object?>();
170170
}
171-
171+
172172
// Output options
173173
if (settings.Output != null && settings.Output.Any())
174174
{

src/GitVersion.App/GitVersionCommand.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ namespace GitVersion;
99
[Description("Generate version information based on Git repository")]
1010
internal class GitVersionCommand : Command<GitVersionSettings>
1111
{
12-
public override int Execute(CommandContext context, GitVersionSettings settings)
13-
{
14-
// The actual logic is handled by the interceptor
15-
// This just returns success to continue normal flow
16-
return 0;
17-
}
12+
public override int Execute(CommandContext context, GitVersionSettings settings) => 0;
1813
}

src/GitVersion.App/GitVersionSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal class GitVersionSettings : CommandSettings
2929
public string[]? Output { get; set; }
3030

3131
[CommandOption("--output-file")]
32-
[Description("Output file when using file output")]
32+
[Description("Output file when using file output")]
3333
public string? OutputFile { get; set; }
3434

3535
[CommandOption("-f|--format")]

src/GitVersion.App/SpectreArgumentParser.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ public Arguments ParseArguments(string[] commandLineArguments)
7272
});
7373

7474
var resultStorage = new ParseResultStorage();
75-
75+
7676
try
7777
{
7878
// Parse the arguments
7979
var interceptor = new ArgumentInterceptor(resultStorage, this.environment, this.fileSystem, this.buildAgent, this.console, this.globbingResolver);
80+
#pragma warning disable CS0618 // Type or member is obsolete
8081
app.Configure(config => config.Settings.Interceptor = interceptor);
82+
#pragma warning restore CS0618 // Type or member is obsolete
8183

8284
var parseResult = app.Run(commandLineArguments);
83-
85+
8486
var result = resultStorage.GetResult();
8587
if (result != null)
8688
{
@@ -92,7 +94,7 @@ public Arguments ParseArguments(string[] commandLineArguments)
9294
// If parsing fails, return default arguments
9395
return CreateDefaultArguments();
9496
}
95-
97+
9698
return CreateDefaultArguments();
9799
}
98100

0 commit comments

Comments
 (0)