diff options
author | Wesley Schwengle <wesleys@opperschaap.net> | 2023-09-13 22:53:04 -0400 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2023-09-20 20:00:10 +0200 |
commit | fa17566b658f8bc42f958a68ff9df634667b4def (patch) | |
tree | 6f98bdaadc0a64a4fcc63d7662861caa80fe4956 /Completion | |
parent | d3394f35939815bb5436b7ce4ca07069444bf78c (diff) | |
download | zsh-fa17566b658f8bc42f958a68ff9df634667b4def.tar.gz zsh-fa17566b658f8bc42f958a68ff9df634667b4def.tar.xz zsh-fa17566b658f8bc42f958a68ff9df634667b4def.zip |
52141: Add trailer token completion for git commit --trailer
Via 842587016d in the git project there has been support for git commit trailer tokens for the bash completion system. This commit adds similar support to zsh. It includes additional hardening of the regexp and allows for tokens which include a '.'. This can be found in git via 9a0ec17606.
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Unix/Command/_git | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 1d4fe20c9..cefc88c5a 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -717,7 +717,7 @@ _git-commit () { {-p,--patch}'[use the interactive patch selection interface to chose which changes to commit]' \ '(--reset-author)--author[override the author name used in the commit]:author name' \ '--date=[override the author date used in the commit]:date' \ - '*--trailer=[add custom trailer(s)]:trailer' \ + '*--trailer=[add custom trailer(s)]:trailer:__git_trailers_tokens' \ '(-s --signoff)'{-s,--signoff}'[add Signed-off-by trailer at the end of the commit message]' \ '(-n --no-verify)'{-n,--no-verify}'[bypass pre-commit and commit-msg hooks]' \ '--allow-empty[allow recording an empty commit]' \ @@ -7413,6 +7413,19 @@ __git_deleted_files () { __git_files --deleted deleted-files 'deleted file' $* } +(( $+functions[__git_trailers_tokens] )) || +__git_trailers_tokens() { + declare -a trailers + local i + + local -a gtrailers=( $(_call_program trailers git config --name-only --get-regexp '^trailer\..*\.key$') ) + for i in $gtrailers; do + i=( ${${(@s:.:)i}[2,-2]} ) + trailers+=( ${(j|.|)i} ) + done + _wanted trailers expl "trailer" compadd -a trailers +} + (( $+functions[__git_modified_files] )) || __git_modified_files () { __git_files --modified modified-files 'modified file' $* |