From 8d529599f13a6162959e470de1d338761e6b0a09 Mon Sep 17 00:00:00 2001 From: Den Delimarsky <53200638+localden@users.noreply.github.com> Date: Sat, 20 Sep 2025 19:54:10 -0700 Subject: [PATCH] Update scripts/powershell/create-new-feature.ps1 Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- scripts/powershell/create-new-feature.ps1 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/powershell/create-new-feature.ps1 b/scripts/powershell/create-new-feature.ps1 index 124396f..780f399 100644 --- a/scripts/powershell/create-new-feature.ps1 +++ b/scripts/powershell/create-new-feature.ps1 @@ -17,7 +17,28 @@ $featureDesc = ($FeatureDescription -join ' ').Trim() # Resolve repository root. Prefer git information when available, but fall back # to the script location so the workflow still functions in repositories that # were initialised with --no-git. -$fallbackRoot = (Resolve-Path (Join-Path $PSScriptRoot "../../..")).Path +function Find-RepositoryRoot { + param( + [string]$StartDir, + [string[]]$Markers = @('.git', 'README.md') + ) + $current = Resolve-Path $StartDir + while ($true) { + foreach ($marker in $Markers) { + if (Test-Path (Join-Path $current $marker)) { + return $current + } + } + $parent = Split-Path $current -Parent + if ($parent -eq $current) { + break + } + $current = $parent + } + # If no marker found, fall back to script root + return (Resolve-Path $StartDir) +} +$fallbackRoot = (Find-RepositoryRoot -StartDir $PSScriptRoot) try { $repoRoot = git rev-parse --show-toplevel 2>$null