From 959705b940dc09b9f7865abceb0c4975874841e0 Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 17 Nov 2025 20:02:50 +0000 Subject: [PATCH 1/8] use migration id for downloading logs --- RELEASENOTES.md | 1 + .../DownloadLogs/DownloadLogsCommandArgs.cs | 1 + .../DownloadLogs/DownloadLogsCommandBase.cs | 8 ++- .../DownloadLogsCommandHandler.cs | 66 +++++++++++++++---- 4 files changed, 62 insertions(+), 14 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index e69de29bb..9e5c742b5 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -0,0 +1 @@ +- Added `--migration-id` option to `download-logs` command to allow downloading logs directly by migration ID without requiring org/repo lookup \ No newline at end of file diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandArgs.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandArgs.cs index 74897d4aa..8795ca52d 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandArgs.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandArgs.cs @@ -5,6 +5,7 @@ public class DownloadLogsCommandArgs : CommandArgs { public string GithubOrg { get; set; } public string GithubRepo { get; set; } + public string MigrationId { get; set; } public string GithubApiUrl { get; set; } [Secret] public string GithubPat { get; set; } diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandBase.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandBase.cs index cd551ca96..70b031c4c 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandBase.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandBase.cs @@ -18,16 +18,19 @@ public class DownloadLogsCommandBase : CommandBase GithubOrg { get; } = new("--github-org") { - IsRequired = true, Description = "GitHub organization to download logs from." }; public virtual Option GithubRepo { get; } = new("--github-repo") { - IsRequired = true, Description = "Target repository to download latest log for." }; + public virtual Option MigrationId { get; } = new("--migration-id") + { + Description = "Migration ID to download logs for. If specified, --github-org and --github-repo are not required." + }; + public virtual Option GithubApiUrl { get; } = new("--github-api-url") { Description = "Target GitHub API URL if not targeting github.com (default: https://api.github.com)." @@ -79,6 +82,7 @@ protected void AddOptions() { AddOption(GithubOrg); AddOption(GithubRepo); + AddOption(MigrationId); AddOption(GithubApiUrl); AddOption(GithubPat); AddOption(MigrationLogFile); diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index bccf84625..6da0fbbe2 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -38,6 +38,21 @@ public async Task Handle(DownloadLogsCommandArgs args) throw new ArgumentNullException(nameof(args)); } + if (args.MigrationId.HasValue()) + { + if (args.GithubOrg.HasValue() || args.GithubRepo.HasValue()) + { + _log.LogWarning("--github-org and --github-repo are ignored when --migration-id is specified."); + } + } + else + { + if (!args.GithubOrg.HasValue() || !args.GithubRepo.HasValue()) + { + throw new OctoshiftCliException("Either --migration-id or both --github-org and --github-repo must be specified."); + } + } + _log.LogWarning("Migration logs are only available for 24 hours after a migration finishes!"); _log.LogInformation("Downloading migration logs..."); @@ -49,22 +64,49 @@ public async Task Handle(DownloadLogsCommandArgs args) throw new OctoshiftCliException($"File {args.MigrationLogFile} already exists! Use --overwrite to overwrite this file."); } - var result = await _retryPolicy.RetryOnResult(async () => await _githubApi.GetMigrationLogUrl(args.GithubOrg, args.GithubRepo), r => r?.MigrationLogUrl.IsNullOrWhiteSpace() ?? false, - "Waiting for migration log to populate..."); + string logUrl; + string migrationId; + string repositoryName; - if (result.Outcome == OutcomeType.Successful && result.Result is null) + if (args.MigrationId.HasValue()) { - throw new OctoshiftCliException($"Migration for repository {args.GithubRepo} not found!"); - } + // Use migration ID directly + migrationId = args.MigrationId; + var migrationResult = await _retryPolicy.RetryOnResult( + async () => await _githubApi.GetMigration(migrationId), + r => string.IsNullOrWhiteSpace(r.MigrationLogUrl), + "Waiting for migration log to populate..."); + + if (migrationResult.Outcome == OutcomeType.Failure) + { + throw new OctoshiftCliException($"Migration log for migration {migrationId} unavailable!"); + } - if (result.Outcome == OutcomeType.Failure) - { - throw new OctoshiftCliException($"Migration log for repository {args.GithubRepo} unavailable!"); + var migration = migrationResult.Result; + logUrl = migration.MigrationLogUrl; + repositoryName = migration.RepositoryName; } + else + { + // Use org/repo to find migration + var result = await _retryPolicy.RetryOnResult(async () => await _githubApi.GetMigrationLogUrl(args.GithubOrg, args.GithubRepo), r => r?.MigrationLogUrl.IsNullOrWhiteSpace() ?? false, + "Waiting for migration log to populate..."); + + if (result.Outcome == OutcomeType.Successful && result.Result is null) + { + throw new OctoshiftCliException($"Migration for repository {args.GithubRepo} not found!"); + } - var (logUrl, migrationId) = result.Result.Value; + if (result.Outcome == OutcomeType.Failure) + { + throw new OctoshiftCliException($"Migration log for repository {args.GithubRepo} unavailable!"); + } + + (logUrl, migrationId) = result.Result.Value; + repositoryName = args.GithubRepo; + } - args.MigrationLogFile ??= $"migration-log-{args.GithubOrg}-{args.GithubRepo}-{migrationId}.log"; + args.MigrationLogFile ??= $"migration-log-{repositoryName}-{migrationId}.log"; if (FileExists(args.MigrationLogFile)) { @@ -76,9 +118,9 @@ public async Task Handle(DownloadLogsCommandArgs args) _log.LogWarning($"Overwriting {args.MigrationLogFile} due to --overwrite option."); } - _log.LogInformation($"Downloading log for repository {args.GithubRepo} to {args.MigrationLogFile}..."); + _log.LogInformation($"Downloading log for repository {repositoryName} to {args.MigrationLogFile}..."); await _httpDownloadService.DownloadToFile(logUrl, args.MigrationLogFile); - _log.LogSuccess($"Downloaded {args.GithubRepo} log to {args.MigrationLogFile}."); + _log.LogSuccess($"Downloaded {repositoryName} log to {args.MigrationLogFile}."); } } From c23aa461bbf5c64d36940d8169a0a0f293bc4a8f Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 19:32:37 +0000 Subject: [PATCH 2/8] fix tests and lint fixes --- .../Commands/DownloadLogs/DownloadLogsCommandHandler.cs | 8 ++++---- .../Commands/DownloadLogs/DownloadLogsCommandTests.cs | 7 ++++--- .../Commands/DownloadLogs/DownloadLogsCommandTests.cs | 7 ++++--- .../gei/Commands/DownloadLogs/DownloadLogsCommandTests.cs | 7 ++++--- src/gei/Commands/DownloadLogs/DownloadLogsCommand.cs | 2 -- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index 6da0fbbe2..e768cfa0f 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -82,9 +82,9 @@ public async Task Handle(DownloadLogsCommandArgs args) throw new OctoshiftCliException($"Migration log for migration {migrationId} unavailable!"); } - var migration = migrationResult.Result; - logUrl = migration.MigrationLogUrl; - repositoryName = migration.RepositoryName; + var (State, RepositoryName, WarningsCount, FailureReason, MigrationLogUrl) = migrationResult.Result; + logUrl = MigrationLogUrl; + repositoryName = RepositoryName; } else { @@ -106,7 +106,7 @@ public async Task Handle(DownloadLogsCommandArgs args) repositoryName = args.GithubRepo; } - args.MigrationLogFile ??= $"migration-log-{repositoryName}-{migrationId}.log"; + args.MigrationLogFile ??= args.MigrationId.HasValue() ? $"migration-log-{repositoryName}-{migrationId}.log" : $"migration-log-{args.GithubOrg}-{repositoryName}-{migrationId}.log"; if (FileExists(args.MigrationLogFile)) { diff --git a/src/OctoshiftCLI.Tests/ado2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs b/src/OctoshiftCLI.Tests/ado2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs index 7d8e52a65..7b371833f 100644 --- a/src/OctoshiftCLI.Tests/ado2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs +++ b/src/OctoshiftCLI.Tests/ado2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs @@ -11,10 +11,11 @@ public void Should_Have_Options() var command = new DownloadLogsCommand(); Assert.NotNull(command); Assert.Equal("download-logs", command.Name); - Assert.Equal(7, command.Options.Count); + Assert.Equal(8, command.Options.Count); - TestHelpers.VerifyCommandOption(command.Options, "github-org", true); - TestHelpers.VerifyCommandOption(command.Options, "github-repo", true); + TestHelpers.VerifyCommandOption(command.Options, "github-org", false); + TestHelpers.VerifyCommandOption(command.Options, "github-repo", false); + TestHelpers.VerifyCommandOption(command.Options, "migration-id", false); TestHelpers.VerifyCommandOption(command.Options, "github-api-url", false); TestHelpers.VerifyCommandOption(command.Options, "github-pat", false); TestHelpers.VerifyCommandOption(command.Options, "migration-log-file", false); diff --git a/src/OctoshiftCLI.Tests/bbs2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs b/src/OctoshiftCLI.Tests/bbs2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs index 0ed0a634d..dc99030b2 100644 --- a/src/OctoshiftCLI.Tests/bbs2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs +++ b/src/OctoshiftCLI.Tests/bbs2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs @@ -11,10 +11,11 @@ public void Should_Have_Options() var command = new DownloadLogsCommand(); Assert.NotNull(command); Assert.Equal("download-logs", command.Name); - Assert.Equal(7, command.Options.Count); + Assert.Equal(8, command.Options.Count); - TestHelpers.VerifyCommandOption(command.Options, "github-org", true); - TestHelpers.VerifyCommandOption(command.Options, "github-repo", true); + TestHelpers.VerifyCommandOption(command.Options, "github-org", false); + TestHelpers.VerifyCommandOption(command.Options, "github-repo", false); + TestHelpers.VerifyCommandOption(command.Options, "migration-id", false); TestHelpers.VerifyCommandOption(command.Options, "github-api-url", false); TestHelpers.VerifyCommandOption(command.Options, "github-pat", false); TestHelpers.VerifyCommandOption(command.Options, "migration-log-file", false); diff --git a/src/OctoshiftCLI.Tests/gei/Commands/DownloadLogs/DownloadLogsCommandTests.cs b/src/OctoshiftCLI.Tests/gei/Commands/DownloadLogs/DownloadLogsCommandTests.cs index 890eff88b..5a98d94d7 100644 --- a/src/OctoshiftCLI.Tests/gei/Commands/DownloadLogs/DownloadLogsCommandTests.cs +++ b/src/OctoshiftCLI.Tests/gei/Commands/DownloadLogs/DownloadLogsCommandTests.cs @@ -11,10 +11,11 @@ public void Should_Have_Options() var command = new DownloadLogsCommand(); Assert.NotNull(command); Assert.Equal("download-logs", command.Name); - Assert.Equal(7, command.Options.Count); + Assert.Equal(8, command.Options.Count); - TestHelpers.VerifyCommandOption(command.Options, "github-target-org", true); - TestHelpers.VerifyCommandOption(command.Options, "target-repo", true); + TestHelpers.VerifyCommandOption(command.Options, "github-target-org", false); + TestHelpers.VerifyCommandOption(command.Options, "target-repo", false); + TestHelpers.VerifyCommandOption(command.Options, "migration-id", false); TestHelpers.VerifyCommandOption(command.Options, "target-api-url", false); TestHelpers.VerifyCommandOption(command.Options, "github-target-pat", false); TestHelpers.VerifyCommandOption(command.Options, "migration-log-file", false); diff --git a/src/gei/Commands/DownloadLogs/DownloadLogsCommand.cs b/src/gei/Commands/DownloadLogs/DownloadLogsCommand.cs index 83661c45b..6d7c36469 100644 --- a/src/gei/Commands/DownloadLogs/DownloadLogsCommand.cs +++ b/src/gei/Commands/DownloadLogs/DownloadLogsCommand.cs @@ -22,13 +22,11 @@ public class DownloadLogsCommand : DownloadLogsCommandBase public override Option GithubRepo { get; } = new("--target-repo") { - IsRequired = true, Description = "Target repository to download latest log for." }; public override Option GithubOrg { get; } = new("--github-target-org") { - IsRequired = true, Description = "Target GitHub organization to download logs from." }; } From e234221f3de2f9d90855ff438398b5f4361b7b9c Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 11:43:58 -0800 Subject: [PATCH 3/8] Update src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Commands/DownloadLogs/DownloadLogsCommandHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index e768cfa0f..7683ba9f3 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -79,7 +79,7 @@ public async Task Handle(DownloadLogsCommandArgs args) if (migrationResult.Outcome == OutcomeType.Failure) { - throw new OctoshiftCliException($"Migration log for migration {migrationId} unavailable!"); + throw new OctoshiftCliException($"Migration log for migration {migrationId} is currently unavailable. Migration logs are only available for 24 hours after a migration finishes. Please ensure the migration ID is correct and the migration has completed recently."); } var (State, RepositoryName, WarningsCount, FailureReason, MigrationLogUrl) = migrationResult.Result; From 8f0387c0a5f403f51bf535c6ebb00334577f7e31 Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 20:05:56 +0000 Subject: [PATCH 4/8] add more test coverage --- .../DownloadLogsCommandHandler.cs | 2 +- .../DownloadLogsCommandHandlerTests.cs | 122 ++++++++++++++++++ 2 files changed, 123 insertions(+), 1 deletion(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index 7683ba9f3..ce5f70081 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -49,7 +49,7 @@ public async Task Handle(DownloadLogsCommandArgs args) { if (!args.GithubOrg.HasValue() || !args.GithubRepo.HasValue()) { - throw new OctoshiftCliException("Either --migration-id or both --github-org and --github-repo must be specified."); + throw new OctoshiftCliException("Either --migration-id (GraphQL migration ID) or both --github-org and --github-repo must be specified."); } } diff --git a/src/OctoshiftCLI.Tests/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandlerTests.cs b/src/OctoshiftCLI.Tests/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandlerTests.cs index ec2a06413..5e1614731 100644 --- a/src/OctoshiftCLI.Tests/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandlerTests.cs +++ b/src/OctoshiftCLI.Tests/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandlerTests.cs @@ -299,4 +299,126 @@ await FluentActions _mockGithubApi.Verify(m => m.GetMigrationLogUrl(githubOrg, repo), Times.Exactly(6)); _mockHttpDownloadService.Verify(m => m.DownloadToFile(It.IsAny(), It.IsAny()), Times.Never()); } + + [Fact] + public async Task Should_Throw_When_Neither_MigrationId_Nor_OrgRepo_Provided() + { + // Act & Assert + var args = new DownloadLogsCommandArgs(); + await FluentAssertions.FluentActions + .Invoking(async () => await _handler.Handle(args)) + .Should().ThrowAsync() + .WithMessage("Either --migration-id (GraphQL migration ID) or both --github-org and --github-repo must be specified."); + } + + [Fact] + public async Task Should_Throw_When_Only_GithubOrg_Provided() + { + // Act & Assert + var args = new DownloadLogsCommandArgs + { + GithubOrg = "test-org" + }; + await FluentAssertions.FluentActions + .Invoking(async () => await _handler.Handle(args)) + .Should().ThrowAsync() + .WithMessage("Either --migration-id (GraphQL migration ID) or both --github-org and --github-repo must be specified."); + } + + [Fact] + public async Task Should_Throw_When_Only_GithubRepo_Provided() + { + // Act & Assert + var args = new DownloadLogsCommandArgs + { + GithubRepo = "test-repo" + }; + await FluentAssertions.FluentActions + .Invoking(async () => await _handler.Handle(args)) + .Should().ThrowAsync() + .WithMessage("Either --migration-id (GraphQL migration ID) or both --github-org and --github-repo must be specified."); + } + + [Fact] + public async Task Should_Log_Warning_When_MigrationId_And_OrgRepo_Both_Provided() + { + // Arrange + const string migrationId = "RM_test123"; + const string githubOrg = "test-org"; + const string githubRepo = "test-repo"; + const string logUrl = "some-url"; + const string repoName = "test-repo-name"; + + _mockGithubApi.Setup(m => m.GetMigration(migrationId)) + .ReturnsAsync((State: "SUCCEEDED", RepositoryName: repoName, WarningsCount: 0, FailureReason: "", MigrationLogUrl: logUrl)); + _mockHttpDownloadService.Setup(m => m.DownloadToFile(It.IsAny(), It.IsAny())); + + // Act + var args = new DownloadLogsCommandArgs + { + MigrationId = migrationId, + GithubOrg = githubOrg, + GithubRepo = githubRepo + }; + await _handler.Handle(args); + + // Assert + _mockLogger.Verify(m => m.LogWarning("--github-org and --github-repo are ignored when --migration-id is specified."), Times.Once); + _mockGithubApi.Verify(m => m.GetMigration(migrationId), Times.Once); + _mockGithubApi.Verify(m => m.GetMigrationLogUrl(It.IsAny(), It.IsAny()), Times.Never); + } + + [Fact] + public async Task Should_Succeed_When_Only_MigrationId_Provided() + { + // Arrange + const string migrationId = "RM_test123"; + const string logUrl = "some-url"; + const string repoName = "test-repo-name"; + const string expectedFileName = $"migration-log-{repoName}-{migrationId}.log"; + + _mockGithubApi.Setup(m => m.GetMigration(migrationId)) + .ReturnsAsync((State: "SUCCEEDED", RepositoryName: repoName, WarningsCount: 0, FailureReason: "", MigrationLogUrl: logUrl)); + _mockHttpDownloadService.Setup(m => m.DownloadToFile(It.IsAny(), It.IsAny())); + + // Act + var args = new DownloadLogsCommandArgs + { + MigrationId = migrationId + }; + await _handler.Handle(args); + + // Assert + _mockGithubApi.Verify(m => m.GetMigration(migrationId), Times.Once); + _mockHttpDownloadService.Verify(m => m.DownloadToFile(logUrl, expectedFileName), Times.Once); + _mockGithubApi.Verify(m => m.GetMigrationLogUrl(It.IsAny(), It.IsAny()), Times.Never); + } + + [Fact] + public async Task Should_Succeed_When_Only_OrgRepo_Provided() + { + // Arrange + const string githubOrg = "test-org"; + const string githubRepo = "test-repo"; + const string logUrl = "some-url"; + const string migrationId = "RM_test123"; + const string expectedFileName = $"migration-log-{githubOrg}-{githubRepo}-{migrationId}.log"; + + _mockGithubApi.Setup(m => m.GetMigrationLogUrl(githubOrg, githubRepo)) + .ReturnsAsync((logUrl, migrationId)); + _mockHttpDownloadService.Setup(m => m.DownloadToFile(It.IsAny(), It.IsAny())); + + // Act + var args = new DownloadLogsCommandArgs + { + GithubOrg = githubOrg, + GithubRepo = githubRepo + }; + await _handler.Handle(args); + + // Assert + _mockGithubApi.Verify(m => m.GetMigrationLogUrl(githubOrg, githubRepo), Times.Once); + _mockHttpDownloadService.Verify(m => m.DownloadToFile(logUrl, expectedFileName), Times.Once); + _mockGithubApi.Verify(m => m.GetMigration(It.IsAny()), Times.Never); + } } From 5acd9c4e48f51b7090571625df433045875fe07e Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 12:07:11 -0800 Subject: [PATCH 5/8] Update src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Commands/DownloadLogs/DownloadLogsCommandHandler.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index ce5f70081..ee243999d 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -82,9 +82,9 @@ public async Task Handle(DownloadLogsCommandArgs args) throw new OctoshiftCliException($"Migration log for migration {migrationId} is currently unavailable. Migration logs are only available for 24 hours after a migration finishes. Please ensure the migration ID is correct and the migration has completed recently."); } - var (State, RepositoryName, WarningsCount, FailureReason, MigrationLogUrl) = migrationResult.Result; - logUrl = MigrationLogUrl; - repositoryName = RepositoryName; + var (_, repositoryName, _, _, migrationLogUrl) = migrationResult.Result; + logUrl = migrationLogUrl; + repositoryName = repositoryName; } else { From ef23f0faa2281d999736b0cdfdeb814abc410191 Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 12:07:37 -0800 Subject: [PATCH 6/8] Update src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Commands/DownloadLogs/DownloadLogsCommandHandler.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index ee243999d..e95702f4c 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -106,7 +106,10 @@ public async Task Handle(DownloadLogsCommandArgs args) repositoryName = args.GithubRepo; } - args.MigrationLogFile ??= args.MigrationId.HasValue() ? $"migration-log-{repositoryName}-{migrationId}.log" : $"migration-log-{args.GithubOrg}-{repositoryName}-{migrationId}.log"; + var defaultFileName = args.MigrationId.HasValue() + ? $"migration-log-{repositoryName}-{migrationId}.log" + : $"migration-log-{args.GithubOrg}-{repositoryName}-{migrationId}.log"; + args.MigrationLogFile ??= defaultFileName; if (FileExists(args.MigrationLogFile)) { From 42f49a9c0d66e96f03c3d4a924e77ae18e343755 Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 20:26:09 +0000 Subject: [PATCH 7/8] Revert "Update src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs" This reverts commit 5acd9c4e48f51b7090571625df433045875fe07e. --- .../Commands/DownloadLogs/DownloadLogsCommandHandler.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index e95702f4c..03c2fba58 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -82,9 +82,9 @@ public async Task Handle(DownloadLogsCommandArgs args) throw new OctoshiftCliException($"Migration log for migration {migrationId} is currently unavailable. Migration logs are only available for 24 hours after a migration finishes. Please ensure the migration ID is correct and the migration has completed recently."); } - var (_, repositoryName, _, _, migrationLogUrl) = migrationResult.Result; - logUrl = migrationLogUrl; - repositoryName = repositoryName; + var (State, RepositoryName, WarningsCount, FailureReason, MigrationLogUrl) = migrationResult.Result; + logUrl = MigrationLogUrl; + repositoryName = RepositoryName; } else { From f68edcb7bad47fe28d8369893cec8376fa2ec59a Mon Sep 17 00:00:00 2001 From: Briana J Date: Mon, 1 Dec 2025 14:40:24 -0800 Subject: [PATCH 8/8] Potential fix for code scanning alert no. 1052: Useless assignment to local variable Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .../Commands/DownloadLogs/DownloadLogsCommandHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs index 03c2fba58..60a64a548 100644 --- a/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs +++ b/src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandHandler.cs @@ -82,7 +82,7 @@ public async Task Handle(DownloadLogsCommandArgs args) throw new OctoshiftCliException($"Migration log for migration {migrationId} is currently unavailable. Migration logs are only available for 24 hours after a migration finishes. Please ensure the migration ID is correct and the migration has completed recently."); } - var (State, RepositoryName, WarningsCount, FailureReason, MigrationLogUrl) = migrationResult.Result; + var (_, RepositoryName, _, _, MigrationLogUrl) = migrationResult.Result; logUrl = MigrationLogUrl; repositoryName = RepositoryName; }