Skip to content

fix: get-pr-context scripts resolve REPO_ROOT one level too shallow after deployment#6

Merged
markhazleton merged 2 commits intomainfrom
copilot/fix-get-pr-context-issue
Mar 31, 2026
Merged

fix: get-pr-context scripts resolve REPO_ROOT one level too shallow after deployment#6
markhazleton merged 2 commits intomainfrom
copilot/fix-get-pr-context-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 31, 2026

Scripts live 2 levels deep in source (scripts/bash/, scripts/powershell/) but are packaged into .documentation/scripts/bash/ and .documentation/scripts/powershell/ — 3 levels deep. The hardcoded ../.. resolved to .documentation/ instead of the repo root, causing CONSTITUTION_EXISTS to always be false and all derived paths to be wrong.

Changes

  • scripts/powershell/get-pr-context.ps1 — replace Resolve-Path "$scriptPath\..\.." with git rev-parse --show-toplevel, falling back to $scriptPath\..\..\..\; $repoRoot is now a plain string so three $repoRoot.Path references are dropped to $repoRoot
  • scripts/bash/get-pr-context.sh — replace cd "$SCRIPT_DIR/../.." with git rev-parse --show-toplevel, falling back to cd "$SCRIPT_DIR/../../.."

Both scripts now match the pattern already used by common.ps1/common.sh (Get-RepoRoot / get_repo_root), which all other scripts depend on correctly.

# Before
$repoRoot = (Resolve-Path "$scriptPath\..\..")   # lands at .documentation/

# After
$gitRoot = try { git rev-parse --show-toplevel 2>$null } catch { $null }
if ($LASTEXITCODE -eq 0 -and $gitRoot) {
    $repoRoot = $gitRoot.Trim()
} else {
    $repoRoot = (Resolve-Path "$scriptPath\..\..\..\").Path   # correct 3-level fallback
}

…yment

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>
Copilot AI changed the title [WIP] Fix repo root resolution in get-pr-context.ps1 fix: get-pr-context scripts resolve REPO_ROOT one level too shallow after deployment Mar 31, 2026
Copilot AI requested a review from markhazleton March 31, 2026 20:00
@markhazleton markhazleton marked this pull request as ready for review March 31, 2026 20:32
@markhazleton markhazleton merged commit cb6c180 into main Mar 31, 2026
1 check passed
@markhazleton markhazleton deleted the copilot/fix-get-pr-context-issue branch March 31, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: get-pr-context.ps1 resolves REPO_ROOT incorrectly (off by one directory level)

2 participants