vde-worktree 0.0.7 → 0.0.8
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.
- package/completions/fish/vw.fish +30 -1
- package/completions/zsh/_vw +38 -1
- package/package.json +1 -1
package/completions/fish/vw.fish
CHANGED
|
@@ -6,6 +6,28 @@ function __vw_worktree_branches
|
|
|
6
6
|
| sort -u
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
function __vw_default_branch
|
|
10
|
+
command git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; or return 0
|
|
11
|
+
|
|
12
|
+
set -l configured (command git config --get vde-worktree.baseBranch 2>/dev/null)
|
|
13
|
+
if test -n "$configured"
|
|
14
|
+
echo $configured
|
|
15
|
+
return
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
command git show-ref --verify --quiet refs/heads/main >/dev/null 2>/dev/null
|
|
19
|
+
and begin
|
|
20
|
+
echo main
|
|
21
|
+
return
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
command git show-ref --verify --quiet refs/heads/master >/dev/null 2>/dev/null
|
|
25
|
+
and begin
|
|
26
|
+
echo master
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
9
31
|
function __vw_current_bin
|
|
10
32
|
set -l tokens (commandline -opc)
|
|
11
33
|
if test (count $tokens) -ge 1
|
|
@@ -66,6 +88,13 @@ for (const worktree of worktrees) {
|
|
|
66
88
|
' 2>/dev/null
|
|
67
89
|
end
|
|
68
90
|
|
|
91
|
+
function __vw_use_candidates_with_meta
|
|
92
|
+
begin
|
|
93
|
+
__vw_worktree_branches
|
|
94
|
+
__vw_default_branch
|
|
95
|
+
end | sort -u
|
|
96
|
+
end
|
|
97
|
+
|
|
69
98
|
function __vw_local_branches
|
|
70
99
|
command git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null; or return 0
|
|
71
100
|
command git for-each-ref --format='%(refname:short)' refs/heads 2>/dev/null | sort -u
|
|
@@ -132,7 +161,7 @@ for __vw_bin in vw vde-worktree
|
|
|
132
161
|
complete -c $__vw_bin -n "__fish_seen_subcommand_from mv" -a "(__vw_local_branches)"
|
|
133
162
|
complete -c $__vw_bin -n "__fish_seen_subcommand_from del" -a "(__vw_worktree_candidates_with_meta)"
|
|
134
163
|
complete -c $__vw_bin -n "__fish_seen_subcommand_from get" -a "(__vw_remote_branches)"
|
|
135
|
-
complete -c $__vw_bin -n "__fish_seen_subcommand_from use" -a "(
|
|
164
|
+
complete -c $__vw_bin -n "__fish_seen_subcommand_from use" -a "(__vw_use_candidates_with_meta)"
|
|
136
165
|
complete -c $__vw_bin -n "__fish_seen_subcommand_from exec" -a "(__vw_worktree_candidates_with_meta)"
|
|
137
166
|
complete -c $__vw_bin -n "__fish_seen_subcommand_from invoke" -a "(__vw_hook_names)"
|
|
138
167
|
complete -c $__vw_bin -n "__fish_seen_subcommand_from lock" -a "(__vw_worktree_candidates_with_meta)"
|
package/completions/zsh/_vw
CHANGED
|
@@ -7,6 +7,24 @@ _vw_worktree_branches_raw() {
|
|
|
7
7
|
| command sort -u
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
_vw_default_branch_raw() {
|
|
11
|
+
command git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return 0
|
|
12
|
+
local configured
|
|
13
|
+
configured="$(command git config --get vde-worktree.baseBranch 2>/dev/null)"
|
|
14
|
+
if [[ -n "${configured}" ]]; then
|
|
15
|
+
print -r -- "${configured}"
|
|
16
|
+
return 0
|
|
17
|
+
fi
|
|
18
|
+
if command git show-ref --verify --quiet refs/heads/main 2>/dev/null; then
|
|
19
|
+
print -r -- "main"
|
|
20
|
+
return 0
|
|
21
|
+
fi
|
|
22
|
+
if command git show-ref --verify --quiet refs/heads/master 2>/dev/null; then
|
|
23
|
+
print -r -- "master"
|
|
24
|
+
return 0
|
|
25
|
+
fi
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
_vw_worktree_candidate_rows_raw() {
|
|
11
29
|
command git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return 0
|
|
12
30
|
local vw_bin="${words[1]:-vw}"
|
|
@@ -110,6 +128,25 @@ _vw_complete_worktree_branches_with_meta() {
|
|
|
110
128
|
_vw_complete_worktree_branches
|
|
111
129
|
}
|
|
112
130
|
|
|
131
|
+
_vw_complete_use_branches() {
|
|
132
|
+
local -a branches
|
|
133
|
+
local default_branch
|
|
134
|
+
branches=("${(@f)$(_vw_worktree_branches_raw)}")
|
|
135
|
+
default_branch="$(_vw_default_branch_raw | command head -n 1)"
|
|
136
|
+
if [[ -n "${default_branch}" ]]; then
|
|
137
|
+
branches+=("${default_branch}")
|
|
138
|
+
fi
|
|
139
|
+
|
|
140
|
+
branches=("${(@u)branches}")
|
|
141
|
+
|
|
142
|
+
if (( ${#branches} > 0 )); then
|
|
143
|
+
_vw_describe_values "branch" "${branches[@]}"
|
|
144
|
+
return 0
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
_vw_complete_worktree_branches
|
|
148
|
+
}
|
|
149
|
+
|
|
113
150
|
_vw_complete_local_branches() {
|
|
114
151
|
local -a values
|
|
115
152
|
values=("${(@f)$(_vw_local_branches_raw)}")
|
|
@@ -235,7 +272,7 @@ _vw() {
|
|
|
235
272
|
;;
|
|
236
273
|
use)
|
|
237
274
|
_arguments \
|
|
238
|
-
"1:branch:
|
|
275
|
+
"1:branch:_vw_complete_use_branches" \
|
|
239
276
|
"--allow-shared[Allow checkout when branch is attached by another worktree]" \
|
|
240
277
|
"--allow-agent[Allow non-TTY execution for use]" \
|
|
241
278
|
"--allow-unsafe[Allow unsafe behavior in non-TTY mode]"
|