Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: git remote set-url completion
- X-seq: zsh-workers 42882
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: pseyfert <pseyfert.mathphys@xxxxxxxxx>
- Subject: Re: git remote set-url completion
- Date: Wed, 30 May 2018 01:46:48 +0200
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1527637614; bh=0u3c0fkA35ZePsgtDuoj2ZH5aNELmA2qvpySIkxWHUM=; h=From:References:To:Subject:Date:From:Subject; b=t30+b8m3Pp0/J7L+6rSchrOrUsuWoOJTAwA5HckGtAh45sggLjfbEI8wX1Zc/4ZEB5dwcozBYK+iu+IV61LQkMmQd2dx/qBvVCwZqvSPoCby/EvtVUKsF0VNwIAqDZQkdmTTl2eH7lKUV/DFgk+mYwfvKYRa8XoxPM42bJ8OGBsSAOmZlmhYhqKDMoPE/TWaWT3kwWowfxbl9QFloYRFZrhnaEcWmQhMohOQaknyfi/YKWD+skZqx0uhd7jhSGShOwm5BzM582A+FbVHBsIbT9VkBt5P0iX5caebekcIg/EwXPYqgLJ5/SRL7KIVf9w1Y/O+spqa2tAglY25Ti5nKA==
- In-reply-to: <20180521204513.GA26538@robusta>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20180521204513.GA26538@robusta>
On 21 May, pseyfert wrote:
>
> I was not happy with the completion of
> git remote set-url <some remote> TAB
>
> in my usage this should yield the same completions as `git clone TAB`
> (a url like https://gitlab.my_project.tld or git@xxxxxxxxxx or some path to a local repository)
git clone doesn't seem to complete http: style URLs either.
> So I put the below patch together which uses __git_repositories (and _urls) instead of _urls.
Thanks for this. I've got a few comments.
> I also saw there was a todo left in _git for doing
> git remote set-url <some remote> <new url> <old url>
> which used to just use _urls for the completion of old url,
> here I get the output of `git remote get-url <some remote> --all`
Except the --all is missing.
> + # TODO: Old URL does not get completed if --push, --add, or --delete are present
With --push, the old URL is, I believe, still valid. And with --delete, it
is the new one that should be excluded.
The (3) exclusion should work. Perhaps add the numbers into the next arg
specifications to make it clearer given that they're being referenced.
> + # TODO: assumes $line[1] is always the remote name
That seems correct to me and not an assumption.
> + _message "the line is: $line"
That looks like leftover debug.
> +(( $+functions[__git_repositories_or_url] )) ||
> +__git_repositories_or_url () {
> + _alternative \
> + 'repositories::__git_repositories' \
> + 'url::_urls'
The tag should be 'urls' rather than 'url'.
> +}
> +
> +(( $+functions[__git_current_remote_url] )) ||
> +__git_current_remote_url () {
> + # TODO: is ${(@)*[1,4]} a proper replacement for $* and passing extra arguments?
NO.
Various styles can affect what _description adds. matcher-list for
example. Don't rely on that.
I'd be inclined to throw away the inherited arguments. A space in the
_arguments spec prevents them from being added:
'3:old url: __git_current_remote_url $line[1]'
Or make the helper function not be a completion function so that you
have something like:
'3:old url:compadd - $(__git_current_remote_url $line[1])'
> + # TODO: add --push to the `git remote get-url` command in case `git remote set-url --push origin <new url> <TAB>` is completed
Adding ${(k)opt_args[--push]} should get you that. It also needs --all
adding in case there are more than one.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author