Skip to content

Commit 2410b6a

Browse files
committed
include CancelationToken parameter for ICommand
1 parent 977393c commit 2410b6a

File tree

15 files changed

+20
-20
lines changed

15 files changed

+20
-20
lines changed

new-cli/Directory.Packages.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
99
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
1010
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
11-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
1211
<PackageVersion Include="Polly" Version="8.3.0" />
1312
<PackageVersion Include="Scriban" Version="5.9.1" />
1413
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />

new-cli/GitVersion.Calculation/CalculateCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CalculateCommand(ILogger logger, IService service, IGitRepository reposit
1818
this.repository = repository;
1919
}
2020

21-
public Task<int> InvokeAsync(CalculateSettings settings)
21+
public Task<int> InvokeAsync(CalculateSettings settings, CancellationToken cancellationToken = default)
2222
{
2323
var value = service.Call();
2424
this.repository.DiscoverRepository(settings.WorkDir.FullName);

new-cli/GitVersion.Cli/GitVersion.Cli.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
1615
<PackageReference Include="System.CommandLine" />
1716

1817
<PackageReference Include="Serilog.Extensions.Logging" />

new-cli/GitVersion.Common.Command/ICommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace GitVersion;
22

33
public interface ICommand<in T>
44
{
5-
public Task<int> InvokeAsync(T settings);
5+
public Task<int> InvokeAsync(T settings, CancellationToken cancellationToken = default);
66
}
77

88
public interface ICommandImpl

new-cli/GitVersion.Configuration/ConfigCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ConfigCommand(ILogger logger, IService service)
1616
this.service = service;
1717
}
1818

19-
public Task<int> InvokeAsync(ConfigSettings settings)
19+
public Task<int> InvokeAsync(ConfigSettings settings, CancellationToken cancellationToken = default)
2020
{
2121
var value = service.Call();
2222
logger.LogInformation($"Command : 'config', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");

new-cli/GitVersion.Configuration/Init/ConfigInitCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ConfigInitCommand(ILogger logger, IService service)
1616
this.service = service;
1717
}
1818

19-
public Task<int> InvokeAsync(ConfigInitSettings settings)
19+
public Task<int> InvokeAsync(ConfigInitSettings settings, CancellationToken cancellationToken = default)
2020
{
2121
var value = service.Call();
2222
logger.LogInformation($"Command : 'config init', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");

new-cli/GitVersion.Configuration/Show/ConfigShowCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ConfigShowCommand(ILogger logger, IService service)
1616
this.service = service;
1717
}
1818

19-
public Task<int> InvokeAsync(ConfigShowSettings settings)
19+
public Task<int> InvokeAsync(ConfigShowSettings settings, CancellationToken cancellationToken = default)
2020
{
2121
var value = service.Call();
2222
logger.LogInformation($"Command : 'config show', LogFile : '{settings.LogFile}', WorkDir : '{settings.WorkDir}' ");

new-cli/GitVersion.Core/GitVersion.Core.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
</ItemGroup>
55
<ItemGroup>
66
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
7-
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
87
<PackageReference Include="Serilog.Extensions.Logging" />
98
<PackageReference Include="Serilog.Sinks.Console" />
109
<PackageReference Include="Serilog.Sinks.File" />

new-cli/GitVersion.Core/Infrastructure/ContainerRegistrar.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ private static Serilog.Core.Logger CreateLogger()
5656
// serilog.sinks.map will defer the configuration of the sink to be on demand
5757
// allowing us to look at the properties set by the enricher to set the path appropriately
5858
.WriteTo.Console()
59-
.WriteTo.Map(LoggingEnricher.LogFilePathPropertyName, (logFilePath, wt) => wt.File(logFilePath), 1)
59+
.WriteTo.Map(LoggingEnricher.LogFilePathPropertyName, (logFilePath, wt) =>
60+
{
61+
if (!string.IsNullOrEmpty(logFilePath)) wt.File(logFilePath);
62+
}, 1)
6063
.CreateLogger();
6164
return logger;
6265
}

new-cli/GitVersion.Core/Infrastructure/LoggingEnricher.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace GitVersion.Infrastructure;
66
public class LoggingEnricher : ILogEventEnricher
77
{
88
public static readonly LoggingLevelSwitch LogLevel = new();
9-
private string? cachedLogFilePath;
10-
private LogEventProperty? cachedLogFilePathProperty;
9+
private string? _cachedLogFilePath;
10+
private LogEventProperty? _cachedLogFilePathProperty;
1111

1212
// this path and level will be set by the LogInterceptor.cs after parsing the settings
1313
public static string Path = string.Empty;
@@ -20,17 +20,17 @@ public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
2020
// we won't have the setting so a default value for the log file will be required
2121
LogEventProperty logFilePathProperty;
2222

23-
if (cachedLogFilePathProperty != null && Path.Equals(cachedLogFilePath))
23+
if (this._cachedLogFilePathProperty != null && Path.Equals(this._cachedLogFilePath))
2424
{
2525
// Path hasn't changed, so let's use the cached property
26-
logFilePathProperty = cachedLogFilePathProperty;
26+
logFilePathProperty = this._cachedLogFilePathProperty;
2727
}
2828
else
2929
{
3030
// We've got a new path for the log. Let's create a new property
3131
// and cache it for future log events to use
32-
cachedLogFilePath = Path;
33-
cachedLogFilePathProperty = logFilePathProperty = propertyFactory.CreateProperty(LogFilePathPropertyName, Path);
32+
this._cachedLogFilePath = Path;
33+
this._cachedLogFilePathProperty = logFilePathProperty = propertyFactory.CreateProperty(LogFilePathPropertyName, Path);
3434
}
3535

3636
logEvent.AddPropertyIfAbsent(logFilePathProperty);

0 commit comments

Comments
 (0)