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:
1 file changed
+11
-3
@@ -98,9 +98,17 @@ _wt_dir() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_wt_setup() {
|
_wt_setup() {
|
||||||
local primary=$1 dir=$2
|
local primary=$1 dir=$2 reply
|
||||||
if [[ -f $dir/.envrc && -f $primary/.envrc && "$(<$dir/.envrc)" == "$(<$primary/.envrc)" ]]; then
|
if [[ -f $dir/.envrc ]]; then
|
||||||
direnv allow "$dir"
|
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
|
fi
|
||||||
if grep -qF 'file://%(buildroot)s/dist/' "$dir/pants.toml" 2>/dev/null; then
|
if grep -qF 'file://%(buildroot)s/dist/' "$dir/pants.toml" 2>/dev/null; then
|
||||||
print -r -- "[python-repos]
|
print -r -- "[python-repos]
|
||||||
|
|||||||
Reference in new issue
Block a user