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() {
82
82
# 2. "user/plugin_name"
83
83
plugin_name_helper () {
84
84
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} "
89
91
echo " $plugin_name "
90
92
}
91
93
@@ -97,7 +99,8 @@ plugin_path_helper() {
97
99
98
100
plugin_already_installed () {
99
101
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]} " ) "
101
104
[ -d " $plugin_path " ] &&
102
105
cd " $plugin_path " &&
103
106
git remote > /dev/null 2>&1
Original file line number Diff line number Diff line change 14
14
15
15
clone () {
16
16
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
19
19
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
21
21
else
22
+ local basename_with_git=" $( basename " $plugin " ) "
23
+ local basename=" ${basename_with_git% .git} "
22
24
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
24
26
fi
25
27
}
26
28
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
30
29
clone_plugin () {
31
30
local plugin=" $1 "
32
31
local branch=" $2 "
You can’t perform that action at this time.
0 commit comments