fix: resolve common.sh/ps1 sourcing from extension scripts directory

Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/spec-kit/sessions/809a1dbf-1301-4312-b4d2-e18f9b3e8b2f
This commit is contained in:
copilot-swe-agent[bot]
2026-03-23 21:30:29 +00:00
committed by GitHub
parent 4f83308540
commit 086421daf1
2 changed files with 31 additions and 3 deletions

View File

@@ -175,7 +175,21 @@ clean_branch_name() {
# to searching for repository markers so the workflow still functions in repositories that
# were initialised with --no-git.
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/common.sh"
# Source common.sh: try the core scripts directory first (standard layout),
# then fall back to the extension's sibling copy.
if [ -f "$SCRIPT_DIR/common.sh" ]; then
source "$SCRIPT_DIR/common.sh"
else
# When running from an extension install (.specify/extensions/git/scripts/bash/),
# resolve common.sh from the project's core scripts directory.
_ext_repo_root="$(cd "$SCRIPT_DIR/../../../../.." 2>/dev/null && pwd)"
if [ -f "$_ext_repo_root/scripts/bash/common.sh" ]; then
source "$_ext_repo_root/scripts/bash/common.sh"
elif [ -f "$SCRIPT_DIR/git-common.sh" ]; then
source "$SCRIPT_DIR/git-common.sh"
fi
fi
if git rev-parse --show-toplevel >/dev/null 2>&1; then
REPO_ROOT=$(git rev-parse --show-toplevel)

View File

@@ -145,8 +145,22 @@ if (-not $fallbackRoot) {
exit 1
}
# Load common functions (includes Resolve-Template)
. "$PSScriptRoot/common.ps1"
# Load common functions (includes Resolve-Template).
# Try the core scripts directory first (standard layout), then fall back
# to the extension's sibling copy.
if (Test-Path "$PSScriptRoot/common.ps1") {
. "$PSScriptRoot/common.ps1"
} else {
# When running from an extension install (.specify/extensions/git/scripts/powershell/),
# resolve common.ps1 from the project's core scripts directory.
$extRepoRoot = (Resolve-Path (Join-Path $PSScriptRoot "../../../../..") -ErrorAction SilentlyContinue)
$coreCommon = if ($extRepoRoot) { Join-Path $extRepoRoot "scripts/powershell/common.ps1" } else { "" }
if ($coreCommon -and (Test-Path $coreCommon)) {
. $coreCommon
} elseif (Test-Path "$PSScriptRoot/git-common.ps1") {
. "$PSScriptRoot/git-common.ps1"
}
}
try {
$repoRoot = git rev-parse --show-toplevel 2>$null