-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.zsh
47 lines (42 loc) · 2.81 KB
/
test.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
source ./gitcd.plugin.zsh
assert_ok() {
[[ $1 == $2 ]] || {
print -P "%B%F{red}Error:"
print -P "%u%B%F{red}expect %b%f%U$1"
print -P "%u%B%F{red}got %b%f%U$2"
exit 1
}
}
# 规则来自 https://github.com/repo-utils/giturl/blob/master/test/giturl.test.js
assert_ok $(_giturl2dir 'git://gitlab.com/edp/logger.git') 'gitlab.com/edp/logger'
assert_ok $(_giturl2dir '[email protected]:edp/logger.git') 'gitlab.com/edp/logger'
assert_ok $(_giturl2dir 'git://github.com/treygriffith/cellar.git') 'github.com/treygriffith/cellar'
assert_ok $(_giturl2dir '[email protected]:frontend/arch/xxx.git') 'gitlab.xxx.com/frontend/arch/xxx'
assert_ok $(_giturl2dir 'https://github.com/banchee/tranquil.git') 'github.com/banchee/tranquil'
assert_ok $(_giturl2dir 'https://github.com/banchee/tranquil') 'github.com/banchee/tranquil'
assert_ok $(_giturl2dir 'http://github.com/banchee/tranquil.git') 'github.com/banchee/tranquil'
assert_ok $(_giturl2dir 'git+https://github.com/banchee/tranquil.git') 'github.com/banchee/tranquil'
assert_ok $(_giturl2dir 'github.com/banchee/tranquil.git') 'github.com/banchee/tranquil'
assert_ok $(_giturl2dir 'https://[email protected]/banchee/tranquil.git') 'github.com/banchee/tranquil'
assert_ok $(_giturl2dir '[email protected]:cnpm/cnpm.git') 'github.com/cnpm/cnpm'
assert_ok $(_giturl2dir 'github.com:cnpm/cnpm.git') 'github.com/cnpm/cnpm'
assert_ok $(_giturl2dir '[email protected]:cnpm/cnpm') 'github.com/cnpm/cnpm'
assert_ok $(_giturl2dir '[email protected]:fengmk2/cnpm.git') 'gitcafe.com/fengmk2/cnpm'
assert_ok $(_giturl2dir '[email protected]:3135914.git') 'gist.github.com/3135914'
GITCD_USEHOST=False
assert_ok $(_giturl2dir 'git://gitlab.com/edp/logger.git') 'edp/logger'
assert_ok $(_giturl2dir '[email protected]:edp/logger.git') 'edp/logger'
assert_ok $(_giturl2dir 'git://github.com/treygriffith/cellar.git') 'treygriffith/cellar'
assert_ok $(_giturl2dir '[email protected]:frontend/arch/xxx.git') 'frontend/arch/xxx'
assert_ok $(_giturl2dir 'https://github.com/banchee/tranquil.git') 'banchee/tranquil'
assert_ok $(_giturl2dir 'https://github.com/banchee/tranquil') 'banchee/tranquil'
assert_ok $(_giturl2dir 'http://github.com/banchee/tranquil.git') 'banchee/tranquil'
assert_ok $(_giturl2dir 'git+https://github.com/banchee/tranquil.git') 'banchee/tranquil'
assert_ok $(_giturl2dir 'github.com/banchee/tranquil.git') 'banchee/tranquil'
assert_ok $(_giturl2dir 'https://[email protected]/banchee/tranquil.git') 'banchee/tranquil'
assert_ok $(_giturl2dir '[email protected]:cnpm/cnpm.git') 'cnpm/cnpm'
assert_ok $(_giturl2dir 'github.com:cnpm/cnpm.git') 'cnpm/cnpm'
assert_ok $(_giturl2dir '[email protected]:cnpm/cnpm') 'cnpm/cnpm'
assert_ok $(_giturl2dir '[email protected]:fengmk2/cnpm.git') 'fengmk2/cnpm'
assert_ok $(_giturl2dir '[email protected]:3135914.git') '3135914'
print -P "%B%F{green}All Pass!"