From 30cd37ba81813e1d61c7c5b29be079e517dcf8a4 Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Tue, 11 Aug 2026 13:40:06 +0900 Subject: [PATCH 1/2] Add worktree environment helper --- AGENTS.md | 3 +++ justfile | 4 ++++ scripts/worktree-env.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 scripts/worktree-env.sh diff --git a/AGENTS.md b/AGENTS.md index 67a5fc53..adbe794c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -42,6 +42,9 @@ AWS_ATHENA_WORKGROUP= AWS_ATHENA_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 ``` diff --git a/justfile b/justfile index 0f89c043..a06c3dff 100644 --- a/justfile +++ b/justfile @@ -5,6 +5,10 @@ TOX_VERSION := "4.34.1" default: @just --list +# Link the main checkout's gitignored .env into a worktree +worktree-env: + bash scripts/worktree-env.sh + # Auto-fix formatting and imports format: # TODO: https://github.com/astral-sh/uv/issues/5903 diff --git a/scripts/worktree-env.sh b/scripts/worktree-env.sh new file mode 100755 index 00000000..a8fcd670 --- /dev/null +++ b/scripts/worktree-env.sh @@ -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" From 4f4874f38207c18b63dcea9891d238752865b514 Mon Sep 17 00:00:00 2001 From: laughingman7743 Date: Tue, 11 Aug 2026 14:27:05 +0900 Subject: [PATCH 2/2] Apply suggestion from @laughingman7743 --- justfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/justfile b/justfile index a06c3dff..e223f613 100644 --- a/justfile +++ b/justfile @@ -7,7 +7,7 @@ default: # Link the main checkout's gitignored .env into a worktree worktree-env: - bash scripts/worktree-env.sh + scripts/worktree-env.sh # Auto-fix formatting and imports format: