Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Restore zsh completions to working completion #1079

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions etc/git-extras-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,12 @@ __gitex_author_names() {
_wanted author-names expl author-name compadd $* - $author_names
}

__gitex_author_emails2() {
echo "$g s"
# read -Ac words
# read -cn cword

local expl
declare -a author_names=($state)

local name="${words[2]}" # name of the author supplied on the command line
local -a authors=("${(f)$(git authors --list)}")
for line in "${authors[@]}"; do
if [ "${line% *}" = "$name" ]; then
local email=${line#*<}
email=${email%>*}

author_names+=("${email#* }")
fi
done

# _wanted author-names expl author-name compadd $* - $author_names
reply=(a b c)
}

__gitex_author_emails() {
compctl -K __gitex_author_emails2
local expl
declare -a author_names
author_names=(${(f)"$(_call_program branchrefs git log --format='%aE' | sort -u)"})
__gitex_command_successful || return
_wanted author-names expl author-name compadd $* - $author_names
}

# subcommands
Expand All @@ -148,10 +129,9 @@ _git-clear() {
}

_git-coauthor() {
compctl -K __gitex_author_emails2 a
# _arguments \
# ':co-author[co-author to add]:__gitex_author_names' \
# ':co-author-email[email address of co-author to add]:__gitex_author_emails'
_arguments \
':co-author[co-author to add]:__gitex_author_names' \
':co-author-email[email address of co-author to add]:__gitex_author_emails'
}

_git-contrib() {
Expand Down