Skip to content

Fix Get-GitRepoRoot type inconsistency causing empty string return from subdirectories#51738

Closed
Copilot wants to merge 2 commits intoadegeo/skillsfrom
copilot/sub-pr-51737
Closed

Fix Get-GitRepoRoot type inconsistency causing empty string return from subdirectories#51738
Copilot wants to merge 2 commits intoadegeo/skillsfrom
copilot/sub-pr-51737

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

The Get-GitRepoRoot function had a type inconsistency bug that returned an empty string when executed from subdirectories, though it worked correctly from the repository root.

Root Cause

Get-Location returns a PathInfo object, while Split-Path returns a string. After the first loop iteration:

$currentPath = Get-Location              # PathInfo object
$parentPath = Split-Path $currentPath    # String
$currentPath = $parentPath               # Now a string

When .git is found in a subsequent iteration, return $currentPath.Path attempts to access the .Path property on a string, which returns an empty string instead of failing.

Changes

  • Initialize $currentPath as a string: $currentPath = (Get-Location).Path
  • Return $currentPath directly instead of $currentPath.Path
  • Maintains type consistency throughout the loop

This ensures the function returns the correct repository root path regardless of the working directory depth.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix repository root handling in skills and prompts addition Fix Get-GitRepoRoot type inconsistency causing empty string return from subdirectories Feb 13, 2026
Copilot AI requested a review from adegeo February 13, 2026 19:43
@adegeo adegeo closed this Feb 13, 2026
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.

2 participants

Comments