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.
This commit is contained in:
Alexander Heldt committed 2026-11-25 08:51:24 +01:00
1 parent bfa3ef7507
commit b794227722
1 file changed
+10 -2
+10 -2
View File
@@ -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
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]