Skip to content

Commit 499ae8b

Browse files
committed
Address PR review: fix repo root detection and no-op test
- Fix repo root fallback in all 20 update-context.sh scripts: walk up from script location to find .specify/ instead of falling back to pwd - Fix repo root fallback in all 20 update-context.ps1 scripts: walk up from script location to find .specify/ instead of falling back to $PWD - Add assertions to test_setup_writes_to_correct_directory: verify expected_dir exists and all command files reside under it
1 parent d0df42e commit 499ae8b

41 files changed

Lines changed: 267 additions & 40 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/specify_cli/integrations/amp/scripts/update-context.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
$ErrorActionPreference = 'Stop'
99

10+
# Derive repo root from script location (walks up to find .specify/)
11+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
1012
$repoRoot = git rev-parse --show-toplevel 2>$null
11-
if (-not $repoRoot) { $repoRoot = $PWD.Path }
13+
if (-not $repoRoot) {
14+
$repoRoot = $scriptDir
15+
while ($repoRoot -ne [System.IO.Path]::GetPathRoot($repoRoot) -and -not (Test-Path (Join-Path $repoRoot '.specify'))) {
16+
$repoRoot = Split-Path -Parent $repoRoot
17+
}
18+
}
1219

1320
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType amp

src/specify_cli/integrations/amp/scripts/update-context.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
set -euo pipefail
1010

11-
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
11+
# Derive repo root from script location (walks up to find .specify/)
12+
_script_dir="$(cd "$(dirname "$0")" && pwd)"
13+
_root="$_script_dir"
14+
while [ "$_root" != "/" ] && [ ! -d "$_root/.specify" ]; do _root="$(dirname "$_root")"; done
15+
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$_root")}"
1216

1317
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" amp

src/specify_cli/integrations/auggie/scripts/update-context.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
$ErrorActionPreference = 'Stop'
99

10+
# Derive repo root from script location (walks up to find .specify/)
11+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
1012
$repoRoot = git rev-parse --show-toplevel 2>$null
11-
if (-not $repoRoot) { $repoRoot = $PWD.Path }
13+
if (-not $repoRoot) {
14+
$repoRoot = $scriptDir
15+
while ($repoRoot -ne [System.IO.Path]::GetPathRoot($repoRoot) -and -not (Test-Path (Join-Path $repoRoot '.specify'))) {
16+
$repoRoot = Split-Path -Parent $repoRoot
17+
}
18+
}
1219

1320
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType auggie

src/specify_cli/integrations/auggie/scripts/update-context.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
set -euo pipefail
1010

11-
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
11+
# Derive repo root from script location (walks up to find .specify/)
12+
_script_dir="$(cd "$(dirname "$0")" && pwd)"
13+
_root="$_script_dir"
14+
while [ "$_root" != "/" ] && [ ! -d "$_root/.specify" ]; do _root="$(dirname "$_root")"; done
15+
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$_root")}"
1216

1317
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" auggie

src/specify_cli/integrations/bob/scripts/update-context.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
$ErrorActionPreference = 'Stop'
99

10+
# Derive repo root from script location (walks up to find .specify/)
11+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
1012
$repoRoot = git rev-parse --show-toplevel 2>$null
11-
if (-not $repoRoot) { $repoRoot = $PWD.Path }
13+
if (-not $repoRoot) {
14+
$repoRoot = $scriptDir
15+
while ($repoRoot -ne [System.IO.Path]::GetPathRoot($repoRoot) -and -not (Test-Path (Join-Path $repoRoot '.specify'))) {
16+
$repoRoot = Split-Path -Parent $repoRoot
17+
}
18+
}
1219

1320
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType bob

src/specify_cli/integrations/bob/scripts/update-context.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
set -euo pipefail
1010

11-
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
11+
# Derive repo root from script location (walks up to find .specify/)
12+
_script_dir="$(cd "$(dirname "$0")" && pwd)"
13+
_root="$_script_dir"
14+
while [ "$_root" != "/" ] && [ ! -d "$_root/.specify" ]; do _root="$(dirname "$_root")"; done
15+
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$_root")}"
1216

1317
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" bob

src/specify_cli/integrations/claude/scripts/update-context.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
$ErrorActionPreference = 'Stop'
99

10+
# Derive repo root from script location (walks up to find .specify/)
11+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
1012
$repoRoot = git rev-parse --show-toplevel 2>$null
11-
if (-not $repoRoot) { $repoRoot = $PWD.Path }
13+
if (-not $repoRoot) {
14+
$repoRoot = $scriptDir
15+
while ($repoRoot -ne [System.IO.Path]::GetPathRoot($repoRoot) -and -not (Test-Path (Join-Path $repoRoot '.specify'))) {
16+
$repoRoot = Split-Path -Parent $repoRoot
17+
}
18+
}
1219

1320
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType claude

src/specify_cli/integrations/claude/scripts/update-context.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
set -euo pipefail
1010

11-
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
11+
# Derive repo root from script location (walks up to find .specify/)
12+
_script_dir="$(cd "$(dirname "$0")" && pwd)"
13+
_root="$_script_dir"
14+
while [ "$_root" != "/" ] && [ ! -d "$_root/.specify" ]; do _root="$(dirname "$_root")"; done
15+
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$_root")}"
1216

1317
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" claude

src/specify_cli/integrations/codebuddy/scripts/update-context.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
$ErrorActionPreference = 'Stop'
99

10+
# Derive repo root from script location (walks up to find .specify/)
11+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
1012
$repoRoot = git rev-parse --show-toplevel 2>$null
11-
if (-not $repoRoot) { $repoRoot = $PWD.Path }
13+
if (-not $repoRoot) {
14+
$repoRoot = $scriptDir
15+
while ($repoRoot -ne [System.IO.Path]::GetPathRoot($repoRoot) -and -not (Test-Path (Join-Path $repoRoot '.specify'))) {
16+
$repoRoot = Split-Path -Parent $repoRoot
17+
}
18+
}
1219

1320
& "$repoRoot/.specify/scripts/powershell/update-agent-context.ps1" -AgentType codebuddy

src/specify_cli/integrations/codebuddy/scripts/update-context.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
set -euo pipefail
1010

11-
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
11+
# Derive repo root from script location (walks up to find .specify/)
12+
_script_dir="$(cd "$(dirname "$0")" && pwd)"
13+
_root="$_script_dir"
14+
while [ "$_root" != "/" ] && [ ! -d "$_root/.specify" ]; do _root="$(dirname "$_root")"; done
15+
REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || echo "$_root")}"
1216

1317
exec "$REPO_ROOT/.specify/scripts/bash/update-agent-context.sh" codebuddy

0 commit comments

Comments
 (0)