Skip to content

Commit 8d52959

Browse files
localdenCopilot
andauthored
Update scripts/powershell/create-new-feature.ps1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 406521c commit 8d52959

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

scripts/powershell/create-new-feature.ps1

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,28 @@ $featureDesc = ($FeatureDescription -join ' ').Trim()
1717
# Resolve repository root. Prefer git information when available, but fall back
1818
# to the script location so the workflow still functions in repositories that
1919
# were initialised with --no-git.
20-
$fallbackRoot = (Resolve-Path (Join-Path $PSScriptRoot "../../..")).Path
20+
function Find-RepositoryRoot {
21+
param(
22+
[string]$StartDir,
23+
[string[]]$Markers = @('.git', 'README.md')
24+
)
25+
$current = Resolve-Path $StartDir
26+
while ($true) {
27+
foreach ($marker in $Markers) {
28+
if (Test-Path (Join-Path $current $marker)) {
29+
return $current
30+
}
31+
}
32+
$parent = Split-Path $current -Parent
33+
if ($parent -eq $current) {
34+
break
35+
}
36+
$current = $parent
37+
}
38+
# If no marker found, fall back to script root
39+
return (Resolve-Path $StartDir)
40+
}
41+
$fallbackRoot = (Find-RepositoryRoot -StartDir $PSScriptRoot)
2142

2243
try {
2344
$repoRoot = git rev-parse --show-toplevel 2>$null

0 commit comments

Comments
 (0)