Skip to content

Conversation

@brianaj
Copy link
Collaborator

@brianaj brianaj commented Dec 11, 2025

External PR from @kine (#1400) to add support for --target-api-url to the add-team-to-repo command for ado2gh.

This enables migrations to GHE.com (GitHub Enterprise Cloud with custom domain) by allowing users to specify a custom API URL when adding teams to repositories.

Changes:

  • Added --target-api-url as optional parameter to AddTeamToRepoCommand
  • Updated script generation to pass targetApiUrl when generating add-team-to-repo commands
  • Updated tests to verify new option
  • Updated release notes

Implements #1398

All tests passing ✅

@github-actions
Copy link

github-actions bot commented Dec 11, 2025

Unit Test Results

  1 files    1 suites   10m 25s ⏱️
971 tests 971 ✅ 0 💤 0 ❌
972 runs  972 ✅ 0 💤 0 ❌

Results for commit 2c1ea1c.

♻️ This comment has been updated with latest results.

@brianaj brianaj marked this pull request as ready for review December 11, 2025 03:23
@brianaj brianaj requested review from a team and Copilot December 11, 2025 03:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for the --target-api-url parameter to the add-team-to-repo command in the ado2gh CLI, enabling migrations to GitHub Enterprise Cloud with custom domains (GHE.com). The implementation follows the established pattern used by other commands like migrate-repo and create-team.

Key changes:

  • Added --target-api-url as an optional parameter to the AddTeamToRepo command
  • Updated script generation logic to include the target API URL when generating add-team-to-repo commands
  • Updated tests to verify the new option is present

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/ado2gh/Commands/AddTeamToRepo/AddTeamToRepoCommandArgs.cs Added TargetApiUrl property to command arguments
src/ado2gh/Commands/AddTeamToRepo/AddTeamToRepoCommand.cs Added TargetApiUrl option and passed it to the API factory in BuildHandler
src/ado2gh/Commands/GenerateScript/GenerateScriptCommandHandler.cs Updated AddMaintainersToGithubRepoScript and AddAdminsToGithubRepoScript methods to accept and include targetApiUrl parameter in generated commands
src/OctoshiftCLI.Tests/ado2gh/Commands/AddTeamToRepo/AddTeamToRepoCommandTests.cs Updated option count and added verification for the new target-api-url option
RELEASENOTES.md Added release note describing the new optional argument
Comments suppressed due to low confidence (1)

src/OctoshiftCLI.Tests/ado2gh/Commands/AddTeamToRepo/AddTeamToRepoCommandTests.cs:64

  • Add a test case to verify that the TargetApiUrl parameter is correctly passed to the ITargetGithubApiFactory.Create method when provided. Following the pattern used in MigrateRepoCommandTests, there should be a test like "It_Uses_Target_Api_Url_When_Provided" that verifies the factory is called with the TargetApiUrl as the first parameter.
        [Fact]
        public void It_Uses_The_Github_Pat_When_Provided()
        {
            const string githubPat = "github-pat";

            var args = new AddTeamToRepoCommandArgs
            {
                GithubOrg = "foo",
                GithubRepo = "blah",
                Team = "some-team",
                Role = "role",
                GithubPat = githubPat
            };

            _command.BuildHandler(args, _serviceProvider);

            _mockGithubApiFactory.Verify(m => m.Create(null, null, githubPat));
        }

Comment on lines +363 to 371
private string AddMaintainersToGithubRepoScript(string adoTeamProject, string githubOrg, string githubRepo, string targetApiUrl) =>
_generateScriptOptions.CreateTeams
? $"gh ado2gh add-team-to-repo --github-org \"{githubOrg}\" --github-repo \"{githubRepo}\" --team \"{adoTeamProject.ReplaceInvalidCharactersWithDash()}-Maintainers\" --role \"maintain\"{(_log.Verbose ? " --verbose" : string.Empty)}"
? $"gh ado2gh add-team-to-repo{(targetApiUrl.HasValue() ? $" --target-api-url \"{targetApiUrl}\"" : string.Empty)} --github-org \"{githubOrg}\" --github-repo \"{githubRepo}\" --team \"{adoTeamProject.ReplaceInvalidCharactersWithDash()}-Maintainers\" --role \"maintain\"{(_log.Verbose ? " --verbose" : string.Empty)}"
: null;

private string AddAdminsToGithubRepoScript(string adoTeamProject, string githubOrg, string githubRepo) =>
private string AddAdminsToGithubRepoScript(string adoTeamProject, string githubOrg, string githubRepo, string targetApiUrl) =>
_generateScriptOptions.CreateTeams
? $"gh ado2gh add-team-to-repo --github-org \"{githubOrg}\" --github-repo \"{githubRepo}\" --team \"{adoTeamProject.ReplaceInvalidCharactersWithDash()}-Admins\" --role \"admin\"{(_log.Verbose ? " --verbose" : string.Empty)}"
? $"gh ado2gh add-team-to-repo{(targetApiUrl.HasValue() ? $" --target-api-url \"{targetApiUrl}\"" : string.Empty)} --github-org \"{githubOrg}\" --github-repo \"{githubRepo}\" --team \"{adoTeamProject.ReplaceInvalidCharactersWithDash()}-Admins\" --role \"admin\"{(_log.Verbose ? " --verbose" : string.Empty)}"
: null;
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test case that verifies when both CreateTeams and TargetApiUrl are set, the generated script includes --target-api-url in the add-team-to-repo commands. This would ensure the integration between the GenerateScript command and the AddTeamToRepo command works correctly when migrating to GHE.com. For example, the test should verify that the generated script contains commands like "gh ado2gh add-team-to-repo --target-api-url "https://example.com/api/v3\" --github-org ..."

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@mulana mulana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

Verify that when both CreateTeams and TargetApiUrl options are set, the
generated script includes --target-api-url in the add-team-to-repo commands.
This ensures proper integration when migrating to GHE.com.
@brianaj brianaj requested a review from mulana December 11, 2025 04:14
@github-actions
Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
ado2gh 72% 70% 718
Octoshift 83% 73% 1746
bbs2gh 83% 78% 663
gei 80% 71% 574
Summary 80% (7757 / 9636) 73% (1846 / 2531) 3701

@brianaj brianaj merged commit 2be9555 into main Dec 11, 2025
34 checks passed
@brianaj brianaj deleted the brianaj/external-pr-1400 branch December 11, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants