Skip to content

Commit 144a291

Browse files
committed
Updates GitVersionApp to implement ICliApp
Refactors `GitVersionApp` to implement `ICliApp` and updates dependency injection to register `GitVersionApp` as `ICliApp`. Adjusts `RunAsync` to include `CancellationToken`, ensuring proper cancellation support.
1 parent 47f00e1 commit 144a291

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

new-cli/GitVersion.Core.Tester/GitVersionApp.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using GitVersion.Git;
2+
using GitVersion.Infrastructure;
23
using Microsoft.Extensions.Logging;
34

45
namespace GitVersion;
56

6-
public class GitVersionApp(ILogger logger, IGitRepository repository)
7+
public class GitVersionApp(ILogger<GitVersionApp> logger, IGitRepository repository) : ICliApp
78
{
8-
#pragma warning disable IDE0060
9-
public Task<int> RunAsync(string[] args)
10-
#pragma warning restore IDE0060
9+
public Task<int> RunAsync(string[] args, CancellationToken cancellationToken)
1110
{
1211
repository.DiscoverRepository(Directory.GetCurrentDirectory());
1312
var branches = repository.Branches.ToList();

new-cli/GitVersion.Core.Tester/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
Console.CancelKeyPress += (_, _) => cts.Cancel();
1515

1616
await using var serviceProvider = RegisterModules(modules);
17-
var app = serviceProvider.GetRequiredService<GitVersionApp>();
18-
var result = await app.RunAsync(args);
17+
var app = serviceProvider.GetRequiredService<ICliApp>();
1918

19+
var result = await app.RunAsync(args, cts.Token).ConfigureAwait(false);
2020
if (!Console.IsInputRedirected) Console.ReadKey();
2121

2222
return result;
@@ -25,7 +25,7 @@ static ServiceProvider RegisterModules(IEnumerable<IGitVersionModule> gitVersion
2525
{
2626
var serviceProvider = new ServiceCollection()
2727
.RegisterModules(gitVersionModules)
28-
.AddSingleton<GitVersionApp>()
28+
.AddSingleton<ICliApp, GitVersionApp>()
2929
.RegisterLogging()
3030
.BuildServiceProvider();
3131

0 commit comments

Comments
 (0)