-
-
Notifications
You must be signed in to change notification settings - Fork 381
Add version command line option #3097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MrHinsh
merged 5 commits into
nkdAgility:main
from
sbouchexbellomie-Philips:copilot/add-version-command-line-option
Jan 21, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
55540d7
Initial plan
Copilot 9b0c4d6
Add version command implementation with tests
Copilot 92f4374
Address code review feedback - remove unused logger field and add tes…
Copilot 792f1df
Fixed typo
sbouchexbellomie-Philips 0078139
adress comments
sbouchexbellomie-Philips File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Hosting; | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
| using MigrationTools.Services; | ||
|
|
||
| namespace MigrationTools.Host.Tests.Commands | ||
| { | ||
| [TestClass()] | ||
| public class VersionCommandTests | ||
| { | ||
| private IHost host; | ||
|
|
||
| [TestInitialize] | ||
| public void Setup() | ||
| { | ||
| host = MigrationToolHost.CreateDefaultBuilder(new string[] { "version", "--skipVersionCheck" }).Build(); | ||
| } | ||
|
|
||
| [TestCleanup] | ||
| public void Cleanup() | ||
| { | ||
| host?.Dispose(); | ||
| } | ||
|
|
||
| [TestMethod, TestCategory("L0")] | ||
| public void VersionCommand_ServiceResolution_ShouldSucceed() | ||
| { | ||
| // Verify that all required services can be resolved | ||
| var migrationToolVersion = host.Services.GetRequiredService<IMigrationToolVersion>(); | ||
| Assert.IsNotNull(migrationToolVersion); | ||
| } | ||
|
|
||
| [TestMethod, TestCategory("L0")] | ||
| public void VersionCommand_GetRunningVersion_ShouldReturnVersionInfo() | ||
| { | ||
| var migrationToolVersion = host.Services.GetRequiredService<IMigrationToolVersion>(); | ||
| var versionInfo = migrationToolVersion.GetRunningVersion(); | ||
|
|
||
| Assert.IsNotNull(versionInfo); | ||
|
Check warning on line 39 in src/MigrationTools.Host.Tests/Commands/VersionCommandTests.cs
|
||
| Assert.IsNotNull(versionInfo.versionString); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Hosting; | ||
| using Microsoft.Extensions.Logging; | ||
| using MigrationTools.Host.Services; | ||
| using MigrationTools.Services; | ||
| using Spectre.Console; | ||
| using Spectre.Console.Cli; | ||
|
|
||
| namespace MigrationTools.Host.Commands | ||
| { | ||
| internal class VersionCommand : CommandBase<VersionCommandSettings> | ||
| { | ||
| private readonly IMigrationToolVersion _migrationToolVersion; | ||
|
|
||
| public VersionCommand( | ||
| IHostApplicationLifetime appLifetime, | ||
| IServiceProvider services, | ||
| IDetectOnlineService detectOnlineService, | ||
| IDetectVersionService2 detectVersionService, | ||
| ILogger<CommandBase<VersionCommandSettings>> logger, | ||
| ITelemetryLogger telemetryLogger, | ||
| IMigrationToolVersion migrationToolVersion, | ||
| IConfiguration configuration, | ||
| ActivitySource activitySource) | ||
| : base(appLifetime, services, detectOnlineService, detectVersionService, logger, telemetryLogger, | ||
| migrationToolVersion, configuration, activitySource) | ||
| { | ||
| _migrationToolVersion = migrationToolVersion; | ||
| } | ||
|
|
||
| internal override Task<int> ExecuteInternalAsync(CommandContext context, VersionCommandSettings settings) | ||
| { | ||
| var versionInfo = _migrationToolVersion.GetRunningVersion(); | ||
|
|
||
| AnsiConsole.MarkupLine($"[bold cyan]Version:[/] {Markup.Escape(versionInfo.versionString)}"); | ||
|
|
||
| if (versionInfo.version.Major == 0) | ||
| { | ||
| AnsiConsole.MarkupLine($"[dim]Git Tag:[/] {Markup.Escape(ThisAssembly.Git.Tag)}"); | ||
| AnsiConsole.MarkupLine($"[dim]Git Branch:[/] {Markup.Escape(ThisAssembly.Git.Branch)}"); | ||
| AnsiConsole.MarkupLine($"[dim]Git Commits:[/] {Markup.Escape(ThisAssembly.Git.Commits)}"); | ||
| } | ||
|
|
||
| return Task.FromResult(0); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| using System.ComponentModel; | ||
| using Spectre.Console.Cli; | ||
|
|
||
| namespace MigrationTools.Host.Commands | ||
| { | ||
| internal class VersionCommandSettings : CommandSettingsBase | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.