1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 10:01:11 +02:00

43359: further review of git remote set-url completion

This commit is contained in:
Oliver Kiddle 2018-08-31 23:10:36 +02:00
parent e754b18ca7
commit 36ac12d0b6
2 changed files with 20 additions and 26 deletions

View file

@ -1,5 +1,8 @@
2018-08-31 Oliver Kiddle <okiddle@yahoo.co.uk> 2018-08-31 Oliver Kiddle <okiddle@yahoo.co.uk>
* 43359: Completion/Unix/Command/_git:
further review of git remote set-url completion
* 42810: pseyfert: Completion/Unix/Command/_git: * 42810: pseyfert: Completion/Unix/Command/_git:
git remote set-url completion git remote set-url completion

View file

@ -3607,12 +3607,7 @@ _git-remote () {
'(-m --master)'{-m,--master=}'[set HEAD of remote to point to given master branch]: :__git_branch_names' \ '(-m --master)'{-m,--master=}'[set HEAD of remote to point to given master branch]: :__git_branch_names' \
'--mirror[do not use separate remotes]::mirror type:(fetch pull)' \ '--mirror[do not use separate remotes]::mirror type:(fetch pull)' \
':name:__git_remotes' \ ':name:__git_remotes' \
':repository:->repository' && ret=0 ':repository:__git_repositories_or_urls' && ret=0
case $state in
(repository)
__git_repositories_or_url && ret=0
;;
esac
;; ;;
(get-url) (get-url)
_arguments -S -s \ _arguments -S -s \
@ -3641,17 +3636,13 @@ _git-remote () {
'*: :__git_branch_names' && ret=0 '*: :__git_branch_names' && ret=0
;; ;;
(set-url) (set-url)
# TODO: Old URL does not get completed if --push, --add, or --delete are present _arguments -S \
# TODO: assumes $line[1] is always the remote name '--push[manipulate push URLs instead of fetch URLs]' \
_message "the line is: $line" '(3)--add[add URL to those already defined]' \
_arguments -S -s \ '(2)--delete[delete all matching URLs]' \
'(3)--push[manipulate push URLs instead of fetch URLs]' \ '1: :__git_remotes' \
'--add[add URL to those already defined]' \ '2:new url:__git_repositories_or_urls' \
'(3)--delete[delete all matching URLs]' \ '3:old url: __git_current_remote_urls ${(k)opt_args[--push]} $line[1]' && ret=0
': :__git_remotes' \
':new url:__git_repositories_or_url' \
':old url:__git_current_remote_url $line[1]' \
&& ret=0
;; ;;
(show) (show)
_arguments -S \ _arguments -S \
@ -6971,19 +6962,19 @@ __git_local_repositories () {
_wanted local-repositories expl 'local repositories' _directories _wanted local-repositories expl 'local repositories' _directories
} }
(( $+functions[__git_repositories_or_url] )) || (( $+functions[__git_repositories_or_urls] )) ||
__git_repositories_or_url () { __git_repositories_or_urls () {
_alternative \ _alternative \
'repositories::__git_repositories' \ 'repositories::__git_repositories' \
'url::_urls' 'urls::_urls'
} }
(( $+functions[__git_current_remote_url] )) || (( $+functions[__git_current_remote_urls] )) ||
__git_current_remote_url () { __git_current_remote_urls () {
# TODO: is ${(@)*[1,4]} a proper replacement for $* and passing extra arguments? local expl
# TODO: add --push to the `git remote get-url` command in case `git remote set-url --push origin <new url> <TAB>` is completed _description remote-urls expl 'current url'
_wanted remote-urls expl 'current urls' \ compadd "$expl[@]" -M 'r:|/=* r:|=*' - ${(f)"$(_call_program remote-urls
compadd ${(@)*[1,4]} - ${${(0)"$(_call_program remote-urls git remote get-url $5)"}%%$'\n'*} git remote get-url "$@" --all)"}
} }
(( $+functions[__git_any_repositories] )) || (( $+functions[__git_any_repositories] )) ||