File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,14 +52,14 @@ get_current_branch() {
5252 return
5353 fi
5454
55- # Then check git if available
56- if git rev-parse --abbrev-ref HEAD > /dev/null 2>&1 ; then
57- git rev-parse --abbrev-ref HEAD
55+ # Then check git if available at the spec-kit root (not parent)
56+ local repo_root=$( get_repo_root)
57+ if has_git; then
58+ git -C " $repo_root " rev-parse --abbrev-ref HEAD
5859 return
5960 fi
6061
6162 # For non-git repos, try to find the latest feature directory
62- local repo_root=$( get_repo_root)
6363 local specs_dir=" $repo_root /specs"
6464
6565 if [[ -d " $specs_dir " ]]; then
Original file line number Diff line number Diff line change @@ -74,19 +74,6 @@ if [ -z "$FEATURE_DESCRIPTION" ]; then
7474 exit 1
7575fi
7676
77- # Function to find the repository root by searching for existing project markers
78- find_repo_root () {
79- local dir=" $1 "
80- while [ " $dir " != " /" ]; do
81- if [ -d " $dir /.git" ] || [ -d " $dir /.specify" ]; then
82- echo " $dir "
83- return 0
84- fi
85- dir=" $( dirname " $dir " ) "
86- done
87- return 1
88- }
89-
9077# Function to get highest number from specs directory
9178get_highest_from_specs () {
9279 local specs_dir=" $1 "
Original file line number Diff line number Diff line change @@ -50,19 +50,21 @@ function Get-CurrentBranch {
5050 if ($env: SPECIFY_FEATURE ) {
5151 return $env: SPECIFY_FEATURE
5252 }
53-
54- # Then check git if available
55- try {
56- $result = git rev- parse -- abbrev- ref HEAD 2> $null
57- if ($LASTEXITCODE -eq 0 ) {
58- return $result
53+
54+ # Then check git if available at the spec-kit root (not parent)
55+ $repoRoot = Get-RepoRoot
56+ if (Test-HasGit ) {
57+ try {
58+ $result = git - C $repoRoot rev- parse -- abbrev- ref HEAD 2> $null
59+ if ($LASTEXITCODE -eq 0 ) {
60+ return $result
61+ }
62+ } catch {
63+ # Git command failed
5964 }
60- } catch {
61- # Git command failed
6265 }
63-
66+
6467 # For non-git repos, try to find the latest feature directory
65- $repoRoot = Get-RepoRoot
6668 $specsDir = Join-Path $repoRoot " specs"
6769
6870 if (Test-Path $specsDir ) {
Original file line number Diff line number Diff line change @@ -41,30 +41,6 @@ if ([string]::IsNullOrWhiteSpace($featureDesc)) {
4141 exit 1
4242}
4343
44- # Resolve repository root. Prefer git information when available, but fall back
45- # to searching for repository markers so the workflow still functions in repositories that
46- # were initialized with --no-git.
47- function Find-RepositoryRoot {
48- param (
49- [string ]$StartDir ,
50- [string []]$Markers = @ (' .git' , ' .specify' )
51- )
52- $current = Resolve-Path $StartDir
53- while ($true ) {
54- foreach ($marker in $Markers ) {
55- if (Test-Path (Join-Path $current $marker )) {
56- return $current
57- }
58- }
59- $parent = Split-Path $current - Parent
60- if ($parent -eq $current ) {
61- # Reached filesystem root without finding markers
62- return $null
63- }
64- $current = $parent
65- }
66- }
67-
6844function Get-HighestNumberFromSpecs {
6945 param ([string ]$SpecsDir )
7046
You can’t perform that action at this time.
0 commit comments