fix(git): fix smart cd to cloned directory in `gccd` function
Diff
1diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
2index eef538b75642edee0e8ab1021e700045e2cfed7b..6ea1d1177c660f19aae6e282c28d0e6325ad360c 100644
3--- a/plugins/git/git.plugin.zsh
4+++ b/plugins/git/git.plugin.zsh
5@@ -166,8 +166,15 @@ alias gclean='git clean --interactive -d'
6 alias gcl='git clone --recurse-submodules'
7 8 function gccd() {
9- command git clone --recurse-submodules "$@"
10- [[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
11+ # get repo URI from args based on valid formats: https://git-scm.com/docs/git-clone#URLS
12+ local repo="${${@[(r)(ssh://*|git://*|ftp(s)#://*|http(s)#://*|*@*)(.git/#)#]}:-$_}"
13+
14+ # clone repository and exit if it fails
15+ command git clone --recurse-submodules "$@" || return
16+
17+ # if last arg passed was a directory, that's where the repo was cloned
18+ # otherwise parse the repo URI and use the last part as the directory
19+ [[ -d "$_" ]] && cd "$_" || cd "${${repo:t}%.git/#}"
20 }
21 compdef _git gccd=git-clone
22