Skip to content

Commit 19099d9

Browse files
gilesknapclaude
andcommitted
refactor(devcontainer): always render postCreate.sh
Previously postCreate.sh only existed when add_claude=yes; the add_claude=no case used a long inline bash string in postCreateCommand. Tidier to always have a script and gate the Claude-specific bits with Jinja {% if add_claude %} inside it, per PR #337 review. The meta repo now has its own .devcontainer/postCreate.sh that mirrors the add_claude=no rendering, and its devcontainer.json calls it the same way. Drift test still passes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dbd0ec7 commit 19099d9

4 files changed

Lines changed: 16 additions & 9 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,5 @@
6969
],
7070
// Mount the parent as /workspaces so we can pip install peers as editable
7171
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
72-
// After the container is created, recreate the venv then make pre-commit first run faster
73-
"postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks"
72+
"postCreateCommand": ".devcontainer/postCreate.sh"
7473
}

.devcontainer/postCreate.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Install Python dependencies and pre-commit hooks
5+
uv venv --clear
6+
uv sync
7+
pre-commit install --install-hooks
8+
9+
# Initialise git submodules if any are declared
10+
[ -f .gitmodules ] && git submodule update --init || true

template/.devcontainer/devcontainer.json.jinja

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,11 @@
100100
}{% endif %}
101101
],
102102
// Mount the parent as /workspaces so we can pip install peers as editable
103-
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",{% if add_claude %}
104-
"postCreateCommand": ".devcontainer/postCreate.sh",
103+
"workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind",
104+
"postCreateCommand": ".devcontainer/postCreate.sh"{% if add_claude %},
105105
"postStartCommand": ".devcontainer/postStart.sh",
106106
// VS Code's Dev Containers extension re-injects its credential bridge
107107
// when the editor attaches — after postStart has already run. Re-run
108108
// the cleanup at attach so the leak is closed before any git operation.
109-
"postAttachCommand": ".devcontainer/postStart.sh"{% else %}
110-
// After the container is created, recreate the venv then make pre-commit first run faster
111-
"postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks"{% endif %}
109+
"postAttachCommand": ".devcontainer/postStart.sh"{% endif %}
112110
}

template/.devcontainer/{% if add_claude %}postCreate.sh{% endif %}.jinja renamed to template/.devcontainer/postCreate.sh.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
set -euo pipefail
3-
3+
{% if add_claude %}
44
# Install Claude Code CLI
55
curl -fsSL https://claude.ai/install.sh | bash
6-
6+
{% endif %}
77
# Install Python dependencies and pre-commit hooks
88
uv venv --clear
99
uv sync

0 commit comments

Comments
 (0)