Skip to content

Commit 0e6668e

Browse files
committed
approvals
1 parent 63ab6b0 commit 0e6668e

File tree

12 files changed

+120
-24
lines changed

12 files changed

+120
-24
lines changed

spec/approvals/cli/generated-script

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ _mygit_completions_filter() {
1010
local result=()
1111

1212
# words the user already typed (excluding the command itself)
13-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
1417

1518
if [[ "${cur:0:1}" == "-" ]]; then
1619
# Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _mygit_completions_filter() {
3841

3942
_mygit_completions() {
4043
local cur=${COMP_WORDS[COMP_CWORD]}
41-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
4248
local compline="${compwords[*]}"
4349

50+
COMPREPLY=()
51+
4452
case "$compline" in
4553
'status'*'--branch')
4654
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur")

spec/approvals/cli/generated-script-alt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ _mycomps_filter() {
1010
local result=()
1111

1212
# words the user already typed (excluding the command itself)
13-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
1417

1518
if [[ "${cur:0:1}" == "-" ]]; then
1619
# Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _mycomps_filter() {
3841

3942
_mycomps() {
4043
local cur=${COMP_WORDS[COMP_CWORD]}
41-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
4248
local compline="${compwords[*]}"
4349

50+
COMPREPLY=()
51+
4452
case "$compline" in
4553
'status'*'--branch')
4654
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mycomps_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur")

spec/approvals/cli/generated-wrapped-script

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ give_comps() {
1111
echo $' local result=()'
1212
echo $''
1313
echo $' # words the user already typed (excluding the command itself)'
14-
echo $' local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
14+
echo $' local used=()'
15+
echo $' if ((COMP_CWORD > 1)); then'
16+
echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
17+
echo $' fi'
1518
echo $''
1619
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
1720
echo $' # Completing an option: offer everything (including options)'
@@ -39,9 +42,14 @@ give_comps() {
3942
echo $''
4043
echo $'_mygit_completions() {'
4144
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
42-
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
45+
echo $' local compwords=()'
46+
echo $' if ((COMP_CWORD > 0)); then'
47+
echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
48+
echo $' fi'
4349
echo $' local compline="${compwords[*]}"'
4450
echo $''
51+
echo $' COMPREPLY=()'
52+
echo $''
4553
echo $' case "$compline" in'
4654
echo $' \'status\'*\'--branch\')'
4755
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format=\'%(refname:short)\' 2>/dev/null)")" -- "$cur")'

spec/approvals/cli/test/completely-tester-1.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ _mygit_completions_filter() {
1818
local result=()
1919

2020
# words the user already typed (excluding the command itself)
21-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
21+
local used=()
22+
if ((COMP_CWORD > 1)); then
23+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
24+
fi
2225

2326
if [[ "${cur:0:1}" == "-" ]]; then
2427
# Completing an option: offer everything (including options)
@@ -46,9 +49,14 @@ _mygit_completions_filter() {
4649

4750
_mygit_completions() {
4851
local cur=${COMP_WORDS[COMP_CWORD]}
49-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
52+
local compwords=()
53+
if ((COMP_CWORD > 0)); then
54+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
55+
fi
5056
local compline="${compwords[*]}"
5157

58+
COMPREPLY=()
59+
5260
case "$compline" in
5361
'status'*'--branch')
5462
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur")

spec/approvals/cli/test/completely-tester-2.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ _mygit_completions_filter() {
1818
local result=()
1919

2020
# words the user already typed (excluding the command itself)
21-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
21+
local used=()
22+
if ((COMP_CWORD > 1)); then
23+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
24+
fi
2225

2326
if [[ "${cur:0:1}" == "-" ]]; then
2427
# Completing an option: offer everything (including options)
@@ -46,9 +49,14 @@ _mygit_completions_filter() {
4649

4750
_mygit_completions() {
4851
local cur=${COMP_WORDS[COMP_CWORD]}
49-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
52+
local compwords=()
53+
if ((COMP_CWORD > 0)); then
54+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
55+
fi
5056
local compline="${compwords[*]}"
5157

58+
COMPREPLY=()
59+
5260
case "$compline" in
5361
'status'*'--branch')
5462
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur")

spec/approvals/cli/test/completely-tester.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ _mygit_completions_filter() {
1818
local result=()
1919

2020
# words the user already typed (excluding the command itself)
21-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
21+
local used=()
22+
if ((COMP_CWORD > 1)); then
23+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
24+
fi
2225

2326
if [[ "${cur:0:1}" == "-" ]]; then
2427
# Completing an option: offer everything (including options)
@@ -46,9 +49,14 @@ _mygit_completions_filter() {
4649

4750
_mygit_completions() {
4851
local cur=${COMP_WORDS[COMP_CWORD]}
49-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
52+
local compwords=()
53+
if ((COMP_CWORD > 0)); then
54+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
55+
fi
5056
local compline="${compwords[*]}"
5157

58+
COMPREPLY=()
59+
5260
case "$compline" in
5361
'status'*'--branch')
5462
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur")

spec/approvals/completions/function

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ send_completions() {
1111
echo $' local result=()'
1212
echo $''
1313
echo $' # words the user already typed (excluding the command itself)'
14-
echo $' local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
14+
echo $' local used=()'
15+
echo $' if ((COMP_CWORD > 1)); then'
16+
echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
17+
echo $' fi'
1518
echo $''
1619
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
1720
echo $' # Completing an option: offer everything (including options)'
@@ -39,9 +42,14 @@ send_completions() {
3942
echo $''
4043
echo $'_completely_completions() {'
4144
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
42-
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
45+
echo $' local compwords=()'
46+
echo $' if ((COMP_CWORD > 0)); then'
47+
echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
48+
echo $' fi'
4349
echo $' local compline="${compwords[*]}"'
4450
echo $''
51+
echo $' COMPREPLY=()'
52+
echo $''
4553
echo $' case "$compline" in'
4654
echo $' \'generate\'*)'
4755
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")'

spec/approvals/completions/script

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ _completely_completions_filter() {
1010
local result=()
1111

1212
# words the user already typed (excluding the command itself)
13-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
1417

1518
if [[ "${cur:0:1}" == "-" ]]; then
1619
# Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _completely_completions_filter() {
3841

3942
_completely_completions() {
4043
local cur=${COMP_WORDS[COMP_CWORD]}
41-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
4248
local compline="${compwords[*]}"
4349

50+
COMPREPLY=()
51+
4452
case "$compline" in
4553
'generate'*)
4654
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")

spec/approvals/completions/script-complete-options

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ _mygit_completions_filter() {
1010
local result=()
1111

1212
# words the user already typed (excluding the command itself)
13-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
1417

1518
if [[ "${cur:0:1}" == "-" ]]; then
1619
# Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _mygit_completions_filter() {
3841

3942
_mygit_completions() {
4043
local cur=${COMP_WORDS[COMP_CWORD]}
41-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
4248
local compline="${compwords[*]}"
4349

50+
COMPREPLY=()
51+
4452
case "$compline" in
4553
*)
4654
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "status commit")" -- "$cur")

spec/approvals/completions/script-only-spaces

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ _completely_completions_filter() {
1010
local result=()
1111

1212
# words the user already typed (excluding the command itself)
13-
local used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
1417

1518
if [[ "${cur:0:1}" == "-" ]]; then
1619
# Completing an option: offer everything (including options)
@@ -38,9 +41,14 @@ _completely_completions_filter() {
3841

3942
_completely_completions() {
4043
local cur=${COMP_WORDS[COMP_CWORD]}
41-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
4248
local compline="${compwords[*]}"
4349

50+
COMPREPLY=()
51+
4452
case "$compline" in
4553
'generate'*)
4654
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")

0 commit comments

Comments
 (0)