chore: configure Codex worktree env setup
This commit is contained in:
parent
f19b0c85f8
commit
54c65d1cd3
2 changed files with 34 additions and 0 deletions
12
.codex/README.md
Normal file
12
.codex/README.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Codex environment
|
||||
|
||||
`environments/environment.toml` contains inline setup commands for macOS
|
||||
in `[setup]` and Windows PowerShell in `[setup.win32]`. Git must be on PATH.
|
||||
|
||||
The setup copies the main Git checkout's root `.env` to the new worktree
|
||||
by locating its shared `.git` directory.
|
||||
It preserves an existing destination and skips copying if the source is missing.
|
||||
The file stays ignored by Git, and its contents are never logged.
|
||||
|
||||
Commit the `.codex` directory so the setup is available in new worktrees.
|
||||
Keep a local `.env` in the main checkout on each machine.
|
||||
22
.codex/environments/environment.toml
Normal file
22
.codex/environments/environment.toml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
version = 1
|
||||
name = "Hydra"
|
||||
|
||||
[setup]
|
||||
script = '''
|
||||
git_dir=$(git rev-parse --path-format=absolute --git-common-dir) || exit 1
|
||||
source_env="$(dirname "$git_dir")/.env"
|
||||
if [ ! -e .env ] && [ -f "$source_env" ]; then
|
||||
cp -n "$source_env" .env
|
||||
fi
|
||||
'''
|
||||
|
||||
[setup.win32]
|
||||
script = '''
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$gitDir = git rev-parse --path-format=absolute --git-common-dir
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not locate the main Git checkout.' }
|
||||
$sourceEnv = Join-Path (Split-Path -Parent $gitDir) '.env'
|
||||
if (!(Test-Path -LiteralPath '.env') -and (Test-Path -LiteralPath $sourceEnv -PathType Leaf)) {
|
||||
[System.IO.File]::Copy($sourceEnv, (Join-Path (Get-Location).Path '.env'), $false)
|
||||
}
|
||||
'''
|
||||
Loading…
Reference in a new issue