From bb4373973546293d07c70e870d164ea11a3c00d5 Mon Sep 17 00:00:00 2001 From: Simon Gagnon Date: Thu, 22 Oct 2026 20:10:49 -0400 Subject: [PATCH] Read worktrunk 0.80's wrapped wt list JSON in the shell helpers. worktrunk 0.80 returns {schema, items: [...]} with the path under .worktree.path; older versions return a plain array with .path. The worktree helpers and wts now accept both. Co-Authored-By: Claude Opus 5.5 --- config/shell/bercail.inc.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/config/shell/bercail.inc.sh b/config/shell/bercail.inc.sh index 16af3a1..8376632 100644 --- a/config/shell/bercail.inc.sh +++ b/config/shell/bercail.inc.sh @@ -24,10 +24,15 @@ d() { alias dev='worktree-dev' alias t='herdr' +# `wt list --format=json` returns a plain array before worktrunk 0.80 and +# {schema, items: [...]} (path under .worktree.path) from 0.80 on. +_wt_list_items_jq='if type == "object" then .items else . end' + _wt_worktree_path_for_branch() { local branch="$1" wt list --format=json 2>/dev/null \ - | jq -r --arg branch "$branch" 'map(select(.branch == $branch)) | .[0].path' + | jq -r --arg branch "$branch" \ + "${_wt_list_items_jq} | map(select(.branch == \$branch)) | .[0] | (.worktree.path? // .path)" } _wt_branch_exists() { @@ -120,7 +125,7 @@ wts() { local branch="$1" if [[ -z "$branch" ]]; then - branch=$(wt list --format=json 2>/dev/null | jq -r '.[].branch' | fzf --header="Select worktree:" --tiebreak=index) + branch=$(wt list --format=json 2>/dev/null | jq -r "${_wt_list_items_jq} | .[].branch" | fzf --header="Select worktree:" --tiebreak=index) [[ -z "$branch" ]] && { echo "No worktree selected"; return 1; } fi