-
Notifications
You must be signed in to change notification settings - Fork 127
Add --target-api-url support to add-team-to-repo command #1484
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
Conversation
Co-authored-by: Copilot <[email protected]>
…RepoCommandTests.cs Co-authored-by: Copilot <[email protected]>
…RepoCommandHandlerTests.cs Co-authored-by: Copilot <[email protected]>
…repo command # Conflicts: # RELEASENOTES.md
Unit Test Results 1 files 1 suites 10m 25s ⏱️ Results for commit 2c1ea1c. ♻️ This comment has been updated with latest results. |
There was a problem hiding this 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-urlas 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));
}
| 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; |
Copilot
AI
Dec 11, 2025
There was a problem hiding this comment.
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 ..."
mulana
left a comment
There was a problem hiding this 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.
External PR from @kine (#1400) to add support for
--target-api-urlto theadd-team-to-repocommand 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:
--target-api-urlas optional parameter toAddTeamToRepoCommandtargetApiUrlwhen generating add-team-to-repo commandsImplements #1398
All tests passing ✅