Skip to content

Commit bde1ac7

Browse files
authored
Merge pull request #1499 from github/o1/push-mvlyxwzkvtxx
Support `--target-api-url` consistently on download-logs commands
2 parents 67a062c + 298fe37 commit bde1ac7

File tree

7 files changed

+50
-10
lines changed

7 files changed

+50
-10
lines changed

RELEASENOTES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
1+
- Fixed `ado2gh generate-script --download-migration-logs` to generate valid commands using `--target-api-url` that work with the `ado2gh download-logs` command
2+
- Added `--target-api-url` support to `ado2gh download-logs` and `bbs2gh download-logs` commands for GHEC data residency scenarios
3+
- Maintained backward compatibility: `--github-api-url` continues to work as an alias for `--target-api-url` in `ado2gh` and `bbs2gh` CLIs

src/Octoshift/Commands/DownloadLogs/DownloadLogsCommandBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public class DownloadLogsCommandBase : CommandBase<DownloadLogsCommandArgs, Down
3131
Description = "Migration ID to download logs for. If specified, --github-org and --github-repo are not required."
3232
};
3333

34-
public virtual Option<string> GithubApiUrl { get; } = new("--github-api-url")
34+
public virtual Option<string> GithubApiUrl { get; } = new("--target-api-url")
3535
{
36-
Description = "Target GitHub API URL if not targeting github.com (default: https://api.github.com)."
36+
Description = "Target GitHub API URL if not targeting github.com (default: https://api.github.com). Also accepts --github-api-url for backward compatibility."
3737
};
3838

3939
public virtual Option<string> GithubPat { get; } = new("--github-pat")

src/OctoshiftCLI.Tests/ado2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using OctoshiftCLI.AdoToGithub.Commands.DownloadLogs;
23
using Xunit;
34

@@ -16,10 +17,22 @@ public void Should_Have_Options()
1617
TestHelpers.VerifyCommandOption(command.Options, "github-org", false);
1718
TestHelpers.VerifyCommandOption(command.Options, "github-repo", false);
1819
TestHelpers.VerifyCommandOption(command.Options, "migration-id", false);
19-
TestHelpers.VerifyCommandOption(command.Options, "github-api-url", false);
20+
TestHelpers.VerifyCommandOption(command.Options, "target-api-url", false);
2021
TestHelpers.VerifyCommandOption(command.Options, "github-pat", false);
2122
TestHelpers.VerifyCommandOption(command.Options, "migration-log-file", false);
2223
TestHelpers.VerifyCommandOption(command.Options, "overwrite", false);
2324
TestHelpers.VerifyCommandOption(command.Options, "verbose", false);
2425
}
26+
27+
[Fact]
28+
public void Should_Support_Github_Api_Url_Alias_For_Backward_Compatibility()
29+
{
30+
// Test that --github-api-url still works as an alias for --target-api-url
31+
var command = new DownloadLogsCommand();
32+
var option = command.Options.FirstOrDefault(o => o.Name == "target-api-url");
33+
34+
Assert.NotNull(option);
35+
Assert.Contains("--target-api-url", option.Aliases);
36+
Assert.Contains("--github-api-url", option.Aliases);
37+
}
2538
}

src/OctoshiftCLI.Tests/bbs2gh/Commands/DownloadLogs/DownloadLogsCommandTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using OctoshiftCLI.BbsToGithub.Commands.DownloadLogs;
23
using Xunit;
34

@@ -16,10 +17,22 @@ public void Should_Have_Options()
1617
TestHelpers.VerifyCommandOption(command.Options, "github-org", false);
1718
TestHelpers.VerifyCommandOption(command.Options, "github-repo", false);
1819
TestHelpers.VerifyCommandOption(command.Options, "migration-id", false);
19-
TestHelpers.VerifyCommandOption(command.Options, "github-api-url", false);
20+
TestHelpers.VerifyCommandOption(command.Options, "target-api-url", false);
2021
TestHelpers.VerifyCommandOption(command.Options, "github-pat", false);
2122
TestHelpers.VerifyCommandOption(command.Options, "migration-log-file", false);
2223
TestHelpers.VerifyCommandOption(command.Options, "overwrite", false);
2324
TestHelpers.VerifyCommandOption(command.Options, "verbose", false);
2425
}
26+
27+
[Fact]
28+
public void Should_Support_Github_Api_Url_Alias_For_Backward_Compatibility()
29+
{
30+
// Test that --github-api-url still works as an alias for --target-api-url
31+
var command = new DownloadLogsCommand();
32+
var option = command.Options.FirstOrDefault(o => o.Name == "target-api-url");
33+
34+
Assert.NotNull(option);
35+
Assert.Contains("--target-api-url", option.Aliases);
36+
Assert.Contains("--github-api-url", option.Aliases);
37+
}
2538
}

src/ado2gh/Commands/DownloadLogs/DownloadLogsCommand.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55

66
namespace OctoshiftCLI.AdoToGithub.Commands.DownloadLogs;
77

8-
public class DownloadLogsCommand : DownloadLogsCommandBase
8+
public sealed class DownloadLogsCommand : DownloadLogsCommandBase
99
{
10-
public DownloadLogsCommand() : base() => AddOptions();
10+
public DownloadLogsCommand() : base()
11+
{
12+
// Add backward compatibility alias for --github-api-url
13+
GithubApiUrl.AddAlias("--github-api-url");
14+
15+
AddOptions();
16+
}
1117
}

src/bbs2gh/Commands/DownloadLogs/DownloadLogsCommand.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55

66
namespace OctoshiftCLI.BbsToGithub.Commands.DownloadLogs;
77

8-
public class DownloadLogsCommand : DownloadLogsCommandBase
8+
public sealed class DownloadLogsCommand : DownloadLogsCommandBase
99
{
10-
public DownloadLogsCommand() => AddOptions();
10+
public DownloadLogsCommand()
11+
{
12+
// Add backward compatibility alias for --github-api-url
13+
GithubApiUrl.AddAlias("--github-api-url");
14+
15+
AddOptions();
16+
}
1117
}

src/gei/Commands/DownloadLogs/DownloadLogsCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace OctoshiftCLI.GithubEnterpriseImporter.Commands.DownloadLogs;
88

9-
public class DownloadLogsCommand : DownloadLogsCommandBase
9+
public sealed class DownloadLogsCommand : DownloadLogsCommandBase
1010
{
1111
public DownloadLogsCommand() : base() => AddOptions();
1212

0 commit comments

Comments
 (0)