[azsdk-cli] fixes tsp init tool#12036
Merged
Merged
Conversation
…iling, and update `GetRepoRemoteUri` to support ssh URIs by converting to https
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request fixes two issues with the tsp init tool's Git repository detection functionality. The changes ensure proper detection of Azure REST API specs repository and handle SSH remote URLs correctly.
Key Changes
- Fixed Git repository root detection in
IsRepoPathForSpecRepomethod - Added SSH to HTTPS URL conversion functionality to handle SSH remotes
- Added comprehensive unit tests for the Git helper functionality
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tools/azsdk-cli/Azure.Sdk.Tools.Cli/Helpers/TypeSpecHelper.cs | Modified to discover repo root before checking remote URI |
| tools/azsdk-cli/Azure.Sdk.Tools.Cli/Helpers/GitHelper.cs | Added SSH to HTTPS URL conversion method and integrated it into remote URI retrieval |
| tools/azsdk-cli/Azure.Sdk.Tools.Cli.Tests/Helpers/GitHelperTests.cs | Added comprehensive unit tests for GitHelper functionality |
richardpark-msft
approved these changes
Sep 11, 2025
samvaity
pushed a commit
that referenced
this pull request
Sep 11, 2025
…iling, and update `GetRepoRemoteUri` to support ssh URIs by converting to https (#12036) Co-authored-by: Christopher Radek <Christopher.Radek@microsoft.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#11956 updated the
tsp initMCP tool to detect if it is being ran inside the azure rest api specs repo.There were 2 issues I encountered with this change:
!typespecHelper.IsRepoPathForSpecRepo(fullOutputDirectory))would always pass in the TypeSpec project subdirectory, but this helper function expected the repo root directory.GetRepoRemoteUrito throw an error. This was also used byIsRepoPathForSpecRepoin order to check if the remote points to the specs repo. This worked fine for https remotes.I made 2 changes:
DiscoverRepoRootwithinIsRepoPathForSpecRepo. The doc string forIsRepoPathForSpecReposays it should work if you pass a path within the repo, so this felt like the right fix.ConvertSshToHttpsmethod in the GitHelper. I think it belongs there instead of in the TypeSpecHelper, as there was another tool (that looks at PR branches) that was also failing for me since I had an SSH remote.