Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ AWS_ATHENA_WORKGROUP=<workgroup>
AWS_ATHENA_SPARK_WORKGROUP=<spark-workgroup>
```

In a git worktree, run `just worktree-env` once to link the main checkout's
gitignored `.env` into the worktree.

```bash
export $(cat .env | xargs) && uv run pytest tests/pyathena/test_file.py -v
```
Expand Down
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ TOX_VERSION := "4.34.1"
default:
@just --list

# Link the main checkout's gitignored .env into a worktree
worktree-env:
scripts/worktree-env.sh

# Auto-fix formatting and imports
format:
# TODO: https://github.com/astral-sh/uv/issues/5903
Expand Down
27 changes: 27 additions & 0 deletions scripts/worktree-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -euo pipefail

worktree_root=$(git rev-parse --show-toplevel)
common_dir=$(git rev-parse --path-format=absolute --git-common-dir)
main_root=$(cd "$(dirname "$common_dir")" && pwd -P)

cd "$worktree_root"

if [ "$(pwd -P)" = "$main_root" ]; then
echo "This is the main checkout; nothing to link."
exit 0
fi

if [ -e .env ] && [ ! -L .env ]; then
echo ".env is already a regular file in this worktree; nothing to link."
exit 0
fi

if [ ! -f "$main_root/.env" ]; then
echo "error: $main_root/.env does not exist" >&2
exit 1
fi

ln -sfn "$main_root/.env" .env
echo "Linked .env -> $main_root/.env"