Skip to content

[azsdk-cli] fixes tsp init tool#12036

Merged
chrisradek merged 1 commit into
Azure:mainfrom
chrisradek:fix-tsp-init
Sep 11, 2025
Merged

[azsdk-cli] fixes tsp init tool#12036
chrisradek merged 1 commit into
Azure:mainfrom
chrisradek:fix-tsp-init

Conversation

@chrisradek
Copy link
Copy Markdown
Member

#11956 updated the tsp init MCP tool to detect if it is being ran inside the azure rest api specs repo.

There were 2 issues I encountered with this change:

  1. Git repo detection always failed. This is because !typespecHelper.IsRepoPathForSpecRepo(fullOutputDirectory)) would always pass in the TypeSpec project subdirectory, but this helper function expected the repo root directory.
  2. SSH remotes would cause GetRepoRemoteUri to throw an error. This was also used by IsRepoPathForSpecRepo in order to check if the remote points to the specs repo. This worked fine for https remotes.

I made 2 changes:

  1. Call DiscoverRepoRoot within IsRepoPathForSpecRepo. The doc string for IsRepoPathForSpecRepo says it should work if you pass a path within the repo, so this felt like the right fix.
  2. I added a ConvertSshToHttps method 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.

…iling, and update `GetRepoRemoteUri` to support ssh URIs by converting to https
Copilot AI review requested due to automatic review settings September 10, 2025 23:18
@github-actions github-actions Bot added the azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli label Sep 10, 2025
Copy link
Copy Markdown
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 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 IsRepoPathForSpecRepo method
  • 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

Comment thread tools/azsdk-cli/Azure.Sdk.Tools.Cli/Helpers/GitHelper.cs
@chrisradek chrisradek merged commit eb33043 into Azure:main Sep 11, 2025
24 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants