Skip to content

Commit a1737ca

Browse files
Copilotmarkhazleton
andcommitted
fix: get-pr-context scripts resolve REPO_ROOT incorrectly after deployment
Scripts live 2 levels deep in source (scripts/bash/, scripts/powershell/) but are deployed 3 levels deep (.documentation/scripts/bash/, .documentation/scripts/powershell/). The hardcoded '../..' resolved to .documentation/ instead of the repo root. Both scripts now use `git rev-parse --show-toplevel` first (always correct), with a 3-level-up directory fallback for non-git environments — matching the pattern already used by common.sh/common.ps1. The PowerShell script's $repoRoot is now a plain string (matching Get-RepoRoot in common.ps1), so three $repoRoot.Path references are updated to $repoRoot. Agent-Logs-Url: https://github.com/markhazleton/spec-kit/sessions/68e9588e-12f7-4aaa-91fd-6c14def251d3 Co-authored-by: markhazleton <223906+markhazleton@users.noreply.github.com>
1 parent f27a8e2 commit a1737ca

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

scripts/bash/get-pr-context.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ set -o pipefail
1818
#==============================================================================
1919

2020
SCRIPT_DIR="$(CDPATH="" cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21-
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
21+
if git rev-parse --show-toplevel >/dev/null 2>&1; then
22+
REPO_ROOT="$(git rev-parse --show-toplevel)"
23+
else
24+
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
25+
fi
2226

2327
PR_NUMBER=""
2428
JSON_MODE=false

scripts/powershell/get-pr-context.ps1

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ $ErrorActionPreference = "Stop"
3232
#==============================================================================
3333

3434
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
35-
$repoRoot = (Resolve-Path "$scriptPath\..\..")
35+
$gitRoot = try { git rev-parse --show-toplevel 2>$null } catch { $null }
36+
if ($LASTEXITCODE -eq 0 -and $gitRoot) {
37+
$repoRoot = $gitRoot.Trim()
38+
} else {
39+
$repoRoot = (Resolve-Path "$scriptPath\..\..\..\").Path
40+
}
3641

3742
#==============================================================================
3843
# Utility Functions
@@ -170,16 +175,16 @@ if (-not $IncludeAllFiles -and $filesChangedTotal -gt $FileSampleLimit) {
170175
}
171176

172177
# Check for constitution
173-
$constitutionPath = Join-Path $repoRoot.Path ".documentation\memory\constitution.md"
178+
$constitutionPath = Join-Path $repoRoot ".documentation\memory\constitution.md"
174179
$constitutionExists = Test-Path $constitutionPath
175180

176181
# Prepare review directory
177-
$reviewDir = Join-Path $repoRoot.Path ".documentation\specs\pr-review"
182+
$reviewDir = Join-Path $repoRoot ".documentation\specs\pr-review"
178183

179184
# Build output
180185
if ($Json) {
181186
$output = @{
182-
REPO_ROOT = $repoRoot.Path
187+
REPO_ROOT = $repoRoot
183188
PR_CONTEXT = @{
184189
enabled = $true
185190
pr_number = $prData.number

0 commit comments

Comments
 (0)