File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44# Get repository root, with fallback for non-git repositories
55get_repo_root () {
6- if git rev-parse --show-toplevel > /dev/null 2>&1 ; then
6+ # Check if current working directory has .specify folder first
7+ if [ -d " $PWD /.specify" ]; then
8+ echo " $PWD "
9+ elif git rev-parse --show-toplevel > /dev/null 2>&1 ; then
710 git rev-parse --show-toplevel
811 else
912 # Fall back to script location for non-git repos
Original file line number Diff line number Diff line change @@ -116,7 +116,15 @@ check_existing_branches() {
116116# were initialised with --no-git.
117117SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
118118
119- if git rev-parse --show-toplevel > /dev/null 2>&1 ; then
119+ # Check if current working directory has .specify folder first
120+ if [ -d " $PWD /.specify" ]; then
121+ REPO_ROOT=" $PWD "
122+ if git rev-parse --show-toplevel > /dev/null 2>&1 ; then
123+ HAS_GIT=true
124+ else
125+ HAS_GIT=false
126+ fi
127+ elif git rev-parse --show-toplevel > /dev/null 2>&1 ; then
120128 REPO_ROOT=$( git rev-parse --show-toplevel)
121129 HAS_GIT=true
122130else
Original file line number Diff line number Diff line change 22# Common PowerShell functions analogous to common.sh
33
44function Get-RepoRoot {
5+ # Check if current working directory has .specify folder first
6+ if (Test-Path (Join-Path $PWD ' .specify' )) {
7+ return $PWD
8+ }
9+
510 try {
611 $result = git rev- parse -- show-toplevel 2> $null
712 if ($LASTEXITCODE -eq 0 ) {
@@ -10,7 +15,7 @@ function Get-RepoRoot {
1015 } catch {
1116 # Git command failed
1217 }
13-
18+
1419 # Fall back to script location for non-git repos
1520 return (Resolve-Path (Join-Path $PSScriptRoot " ../../.." )).Path
1621}
Original file line number Diff line number Diff line change @@ -133,16 +133,27 @@ if (-not $fallbackRoot) {
133133 exit 1
134134}
135135
136- try {
137- $repoRoot = git rev- parse -- show-toplevel 2> $null
138- if ($LASTEXITCODE -eq 0 ) {
139- $hasGit = $true
140- } else {
141- throw " Git not available"
136+ # Check if current working directory has .specify folder first
137+ if (Test-Path (Join-Path $PWD ' .specify' )) {
138+ $repoRoot = $PWD
139+ try {
140+ git rev- parse -- show-toplevel 2> $null | Out-Null
141+ $hasGit = ($LASTEXITCODE -eq 0 )
142+ } catch {
143+ $hasGit = $false
144+ }
145+ } else {
146+ try {
147+ $repoRoot = git rev- parse -- show-toplevel 2> $null
148+ if ($LASTEXITCODE -eq 0 ) {
149+ $hasGit = $true
150+ } else {
151+ throw " Git not available"
152+ }
153+ } catch {
154+ $repoRoot = $fallbackRoot
155+ $hasGit = $false
142156 }
143- } catch {
144- $repoRoot = $fallbackRoot
145- $hasGit = $false
146157}
147158
148159Set-Location $repoRoot
You can’t perform that action at this time.
0 commit comments