File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ set -o pipefail
1818# ==============================================================================
1919
2020SCRIPT_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
2327PR_NUMBER=" "
2428JSON_MODE=false
Original file line number Diff line number Diff 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
180185if ($Json ) {
181186 $output = @ {
182- REPO_ROOT = $repoRoot.Path
187+ REPO_ROOT = $repoRoot
183188 PR_CONTEXT = @ {
184189 enabled = $true
185190 pr_number = $prData.number
You can’t perform that action at this time.
0 commit comments