From b7942277222d921806b22c8098365b9e57f8cae2 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Wed, 25 Nov 2026 08:51:24 +0100 Subject: [PATCH] pinwheel: Ask before allowing a worktree's `.envrc` that differs from main's wt allowed a new worktree's .envrc only when it matched the primary checkout's, and left it blocked otherwise. A branch based on an older main has an older .envrc, so its worktree stayed blocked, `direnv exec` failed, no .bsp/pants.json was written and Metals set up scala-cli instead. The warning saying so scrolled away when a review started Emacs. It now compares with main's .envrc: the same content is allowed as before, and different content is shown as a diff with a y/N prompt before anything else runs. Comparing with main rather than the primary's working copy also stops wt allowing content that was never approved in the primary. --- hosts/pinwheel/modules/work/wt.zsh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hosts/pinwheel/modules/work/wt.zsh b/hosts/pinwheel/modules/work/wt.zsh index 803d757..04a3d66 100644 --- a/hosts/pinwheel/modules/work/wt.zsh +++ b/hosts/pinwheel/modules/work/wt.zsh @@ -98,9 +98,17 @@ _wt_dir() { } _wt_setup() { - local primary=$1 dir=$2 - if [[ -f $dir/.envrc && -f $primary/.envrc && "$(<$dir/.envrc)" == "$(<$primary/.envrc)" ]]; then - direnv allow "$dir" + local primary=$1 dir=$2 reply + if [[ -f $dir/.envrc ]]; then + if git -C "$dir" diff --quiet main -- .envrc; then + direnv allow "$dir" + else + print -r -- "wt: $dir/.envrc differs from main's:" + git --no-pager -C "$dir" diff main -- .envrc + read -q "reply?wt: allow it? [y/N] " + print + [[ $reply == y ]] && direnv allow "$dir" + fi fi if grep -qF 'file://%(buildroot)s/dist/' "$dir/pants.toml" 2>/dev/null; then print -r -- "[python-repos]