File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,12 @@ tpm_plugins_list_helper() {
8282# 2. "user/plugin_name"
8383plugin_name_helper () {
8484 local plugin=" $1 "
85- # get only the part after the last slash, e.g. "plugin_name.git"
86- local plugin_basename=" $( basename " $plugin " ) "
87- # remove ".git" extension (if it exists) to get only "plugin_name"
88- local plugin_name=" ${plugin_basename% .git} "
85+ # get only the last two path segments as author/repo
86+ IFS=' /' read -ra plugin <<< " $plugin"
87+ plugin=" ${plugin[*]: -2: 1} /${plugin[*]: -1} "
88+
89+ # remove ".git" extension (if it exists) to get only "plugin_name"
90+ local plugin_name=" ${plugin% .git} "
8991 echo " $plugin_name "
9092}
9193
@@ -97,7 +99,8 @@ plugin_path_helper() {
9799
98100plugin_already_installed () {
99101 local plugin=" $1 "
100- local plugin_path=" $( plugin_path_helper " $plugin " ) "
102+ IFS=' #' read -ra plugin <<< " $plugin"
103+ local plugin_path=" $( plugin_path_helper " ${plugin[0]} " ) "
101104 [ -d " $plugin_path " ] &&
102105 cd " $plugin_path " &&
103106 git remote > /dev/null 2>&1
Original file line number Diff line number Diff line change 1414
1515clone () {
1616 local plugin=" $1 "
17- local branch=" $2 "
18- if [ -n " $branch " ]; then
17+ [[ -z " $2 " ]] && local branch=" " || local branch= " --branch $2 "
18+ if [[ ! $plugin == * " https:// " * ] ]; then
1919 cd " $( tpm_path) " &&
20- GIT_TERMINAL_PROMPT=0 git clone -b " $branch " --single-branch --recursive " $plugin " > /dev/null 2>&1
20+ GIT_TERMINAL_PROMPT=0 git clone $branch --single-branch --recursive " https://git::@github.com/ $plugin " $plugin > /dev/null 2>&1
2121 else
22+ local basename_with_git=" $( basename " $plugin " ) "
23+ local basename=" ${basename_with_git% .git} "
2224 cd " $( tpm_path) " &&
23- GIT_TERMINAL_PROMPT=0 git clone --single-branch --recursive " $plugin " > /dev/null 2>&1
25+ GIT_TERMINAL_PROMPT=0 git clone $branch --single-branch --recursive " $basename " $basename > /dev/null 2>&1
2426 fi
2527}
2628
27- # tries cloning:
28- # 1. plugin name directly - works if it's a valid git url
29- # 2. expands the plugin name to point to a GitHub repo and tries cloning again
3029clone_plugin () {
3130 local plugin=" $1 "
3231 local branch=" $2 "
You can’t perform that action at this time.
0 commit comments