Skip to content

Commit 358fe37

Browse files
committed
fix: resolve repo root from working directory, not script location
Scripts are now in the package, not the project. Fallback repo root detection was walking up from the script's location (inside pi-spec-kit) instead of from the current working directory (the user's project). This caused specs/ to be created in the wrong repo.
1 parent 36c09a8 commit 358fe37

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

scripts/create-new-feature.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,12 @@ clean_branch_name() {
164164
# Resolve repository root. Prefer git information when available, but fall back
165165
# to searching for repository markers so the workflow still functions in repositories that
166166
# were initialised with --no-git.
167-
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
168-
169167
if git rev-parse --show-toplevel >/dev/null 2>&1; then
170168
REPO_ROOT=$(git rev-parse --show-toplevel)
171169
HAS_GIT=true
172170
else
173-
REPO_ROOT="$(find_repo_root "$SCRIPT_DIR")"
171+
# Walk up from current working directory, not script location
172+
REPO_ROOT="$(find_repo_root "$PWD")"
174173
if [ -z "$REPO_ROOT" ]; then
175174
echo "Error: Could not determine repository root. Please run this script from within the repository." >&2
176175
exit 1

scripts/setup-plan.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ get_repo_root() {
2626
if git rev-parse --show-toplevel >/dev/null 2>&1; then
2727
git rev-parse --show-toplevel
2828
else
29-
# Walk up from script directory looking for project markers
29+
# Walk up from current working directory looking for project markers
3030
local dir
31-
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
31+
dir="$PWD"
3232
while [ "$dir" != "/" ]; do
3333
if [ -d "$dir/.git" ] || [ -d "$dir/.specify" ]; then
3434
echo "$dir"

0 commit comments

Comments
 (0)