File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
2243try {
2344 $repoRoot = git rev- parse -- show-toplevel 2> $null
You can’t perform that action at this time.
0 commit comments