wtcode 0.4.0__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wtcode/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """wtcode -- launch your favorite code tool in a git worktree."""
2
2
 
3
- __version__ = "0.4.0"
3
+ __version__ = "0.5.0"
wtcode/wtcode.sh CHANGED
@@ -5,6 +5,14 @@
5
5
  # Created: 2026-02-03
6
6
  set -eu
7
7
  shopt -s extglob
8
+
9
+ # declare all WTCODE_* env vars and their defaults in one place
10
+ : ${WTCODE_CMD:=}
11
+ : ${WTCODE_USE_CURRENT_BRANCH:=false}
12
+ : ${WTCODE_TMUX_MODE:=send-keys}
13
+ : ${WTCODE_TERMINAL_MODE:=send-keys}
14
+ : ${WTCODE_DEBUG:=}
15
+
8
16
  ${WTCODE_DEBUG:+set -x}
9
17
 
10
18
  --msg() { echo "wtcode: $*" >&2; }
@@ -20,7 +28,7 @@ ${WTCODE_DEBUG:+set -x}
20
28
  sed 's/^-//; s/-$//' # trim leading/trailing hyphens
21
29
  }
22
30
 
23
- WTCODE_VERSION=0.4.0
31
+ WTCODE_VERSION=0.5.0
24
32
  --version() { echo "wtcode $WTCODE_VERSION"; }
25
33
  --help() {
26
34
  cat <<USAGE
@@ -42,6 +50,10 @@ Usage: wtcode [BRANCH] [CMD [CMD-ARGS...]]
42
50
 
43
51
  Environment variables:
44
52
  WTCODE_CMD Default tool to launch (e.g., claude, lazygit, vim)
53
+ WTCODE_USE_CURRENT_BRANCH
54
+ When creating a brand-new branch, fork it from the
55
+ current HEAD instead of the default: origin/HEAD
56
+ (falling back to origin/main, then origin/master)
45
57
  WTCODE_TMUX_MODE When in tmux, control how the tool is launched:
46
58
  send-keys - send command to current pane (default in tmux)
47
59
  split-window - create split pane with send-keys
@@ -68,12 +80,33 @@ USAGE
68
80
 
69
81
  # commands to try as default, in order of preference
70
82
  WTCODE_CMDS_TO_TRY=(
71
- ${WTCODE_CMD:-}
83
+ $WTCODE_CMD
72
84
  claude
73
85
  aider
74
86
  codex
75
87
  )
76
88
 
89
+ ###############################################################################
90
+ ## --default-base-ref -- ref to fork a brand-new branch from
91
+ ###############################################################################
92
+ # defaults to origin/HEAD (falling back to origin/main, then origin/master),
93
+ # so new worktrees start from the repo's default branch instead of whatever
94
+ # happens to be checked out where wtcode was invoked. set
95
+ # WTCODE_USE_CURRENT_BRANCH=true to restore the old behavior of forking from
96
+ # the current HEAD. only consults local remote-tracking refs -- never
97
+ # touches the network.
98
+ --default-base-ref() {
99
+ if [[ $WTCODE_USE_CURRENT_BRANCH == true ]]; then
100
+ git rev-parse HEAD
101
+ return
102
+ fi
103
+ local ref
104
+ for ref in origin/HEAD origin/main origin/master; do
105
+ git rev-parse --verify -q "$ref" &>/dev/null && { echo "$ref"; return; }
106
+ done
107
+ git rev-parse HEAD
108
+ }
109
+
77
110
  ###############################################################################
78
111
  ## --enter-git-worktree -- select branch and create/switch worktree
79
112
  ###############################################################################
@@ -129,9 +162,13 @@ WTCODE_CMDS_TO_TRY=(
129
162
  printf '%s\t%s %s\t%s %s %s%s\n' \
130
163
  "$branch" "$ind" "$name_shown" "$date_shown" "$hash_shown" "$upstream_shown" "$subject"
131
164
  done |
132
- fzf --ansi --color --tmux --print-query --delimiter=$'\t' --with-nth=2 --nth=1 \
165
+ fzf --ansi --color --tmux 90%,70% --print-query --delimiter=$'\t' --with-nth=2 --nth=1 \
133
166
  --preview 'echo {3}' --preview-window 'down:2:wrap' \
134
- --prompt 'wtcode: select worktree/branch (prefix : to create new) > ' |
167
+ --header "$(
168
+ echo '[wtcode] Select the worktree/branch or create new to launch your code tool in it.'
169
+ echo ' Typing colons `:` avoids selecting an existing one to create new with similar names.'
170
+ )" \
171
+ --prompt '> ' |
135
172
  cut -f1 |
136
173
  tail -1
137
174
  )
@@ -230,9 +267,14 @@ WTCODE_CMDS_TO_TRY=(
230
267
  --msg "creating worktree for branch: $branch_name"
231
268
  git worktree add -B "$branch_name" "$worktree_path" "$(git rev-parse "$branch_name")"
232
269
  else
233
- # fork the current HEAD and create the new worktree
234
- --msg "creating worktree with new branch: $branch_name"
235
- git worktree add -b "$branch_name" "$worktree_path" "$(git rev-parse HEAD)"
270
+ # fork a base ref and create the new worktree: defaults to origin/HEAD
271
+ # (falling back to origin/main, origin/master, then the current HEAD);
272
+ # set WTCODE_USE_CURRENT_BRANCH=true to always fork from the current
273
+ # branch instead
274
+ local base_ref
275
+ base_ref=$(--default-base-ref)
276
+ --msg "creating worktree with new branch: $branch_name (from $base_ref)"
277
+ git worktree add -b "$branch_name" "$worktree_path" "$base_ref"
236
278
  fi
237
279
  cd "$worktree_path"
238
280
 
@@ -446,7 +488,7 @@ APPLESCRIPT
446
488
  # when inside tmux, default to send-keys for command history access
447
489
  # set WTCODE_TMUX_MODE=exec to opt out and exec directly
448
490
  if [[ -n ${TMUX:-} ]] && type tmux &>/dev/null; then
449
- local mode=${WTCODE_TMUX_MODE:-send-keys}
491
+ local mode=$WTCODE_TMUX_MODE
450
492
 
451
493
  case $mode in
452
494
  send-keys|split-window|new-window)
@@ -485,7 +527,7 @@ APPLESCRIPT
485
527
  # outside tmux: reuse the current tab/window if the terminal app supports
486
528
  # it (see --terminal-send-keys). set WTCODE_TERMINAL_MODE=exec to opt out
487
529
  if [[ -z ${TMUX:-} ]]; then
488
- local mode=${WTCODE_TERMINAL_MODE:-send-keys}
530
+ local mode=$WTCODE_TERMINAL_MODE
489
531
  case $mode in
490
532
  send-keys)
491
533
  if --terminal-send-keys "$@"; then
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wtcode
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: Launch your favorite code tool in a git worktree
5
5
  Author-email: Jaeho Shin <netj@sparcs.org>
6
6
  License-Expression: MIT
@@ -82,6 +82,7 @@ WTCODE_CMD=cursor wtcode feature # use cursor as default tool
82
82
  | Variable | Description |
83
83
  |---|---|
84
84
  | `WTCODE_CMD` | Default tool to launch (e.g., `claude`, `lazygit`, `vim`, `cursor`) |
85
+ | `WTCODE_USE_CURRENT_BRANCH` | When creating a brand-new branch, fork it from the current HEAD instead of the default: `origin/HEAD` (falling back to `origin/main`, then `origin/master`) |
85
86
  | `WTCODE_DEBUG` | Enable debug tracing when set to any value |
86
87
  | `GIT_WORKTREE_ROOT` | Override the directory where worktrees are created |
87
88
 
@@ -0,0 +1,9 @@
1
+ wtcode/__init__.py,sha256=nbWCIJu9WB6FsYqofznzsWb1GwPw1td8hQEnu2FAYJ4,89
2
+ wtcode/__main__.py,sha256=hOvSYANO-q_rf2yy-AQoEOr18KFRSOF8Ezosf8eeFmM,335
3
+ wtcode/wtcode.sh,sha256=tkm04c_aArDTAd3PWCBAvayWfsHe7227oUyafFqxNMo,22879
4
+ wtcode-0.5.0.dist-info/licenses/LICENSE,sha256=MV9gr1nAVj5R60EM2BQuBhBxCG5V9ulX6-Ep_-LcLqA,1067
5
+ wtcode-0.5.0.dist-info/METADATA,sha256=UPiHK_0pi1vWGZ22c1ker-cW70dq2hw3eelfsJxB-ec,4327
6
+ wtcode-0.5.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
7
+ wtcode-0.5.0.dist-info/entry_points.txt,sha256=QkSPHU86FQa-ujQk07fF4sX4DBQgWzDtgusop4AA5bc,48
8
+ wtcode-0.5.0.dist-info/top_level.txt,sha256=oftTSYYjDMqt33wa0c9MC15KuQ3eyRyoTLXy3PdkVfE,7
9
+ wtcode-0.5.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- wtcode/__init__.py,sha256=TqbbEAt77M6Nx-V2Hn5cdAYQHAuTIzcW1KhT-e_nzhw,89
2
- wtcode/__main__.py,sha256=hOvSYANO-q_rf2yy-AQoEOr18KFRSOF8Ezosf8eeFmM,335
3
- wtcode/wtcode.sh,sha256=4jJihpDcSMISByTOW7zo77xDk6bxstQWCEc3d6d-cX4,21098
4
- wtcode-0.4.0.dist-info/licenses/LICENSE,sha256=MV9gr1nAVj5R60EM2BQuBhBxCG5V9ulX6-Ep_-LcLqA,1067
5
- wtcode-0.4.0.dist-info/METADATA,sha256=tltadRB3o50NbV1Pwd0NhNLte-ezlBXRceRFSrAzs_I,4137
6
- wtcode-0.4.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
7
- wtcode-0.4.0.dist-info/entry_points.txt,sha256=QkSPHU86FQa-ujQk07fF4sX4DBQgWzDtgusop4AA5bc,48
8
- wtcode-0.4.0.dist-info/top_level.txt,sha256=oftTSYYjDMqt33wa0c9MC15KuQ3eyRyoTLXy3PdkVfE,7
9
- wtcode-0.4.0.dist-info/RECORD,,
File without changes