Skip to content

Commit 4c08bc0

Browse files
committed
refactor: change all code comments to English
1 parent 6e657dc commit 4c08bc0

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

gitcd.plugin.zsh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
gitcd() {
22
basedir="$HOME/Code"
3-
# 如果存在全局的 GITCD_HOME,就用它
3+
# If global GITCD_HOME exists, use it
44
[[ -n $GITCD_HOME ]] && {
55
basedir=$GITCD_HOME
66
}
77

8-
# 用户传入的参数
8+
# User input parameter
99
url=$1
1010

11-
# 忘记输入参数,就跳出
11+
# If no parameter is provided, exit
1212
[[ $url == "" ]] && {
13-
# 显示红色加粗
13+
# Display in red and bold
1414
print -P "%B%F{red}[gitcd] Please input your repo url."
1515
return
1616
}
1717

18-
# 通过 git url 计算出路径来
18+
# Calculate the directory path from the git URL
1919
dir=$(_giturl2dir $url)
2020
target=$basedir/$dir
2121

22-
# 如果文件夹已经存在,那直接 cd 过去就好了
22+
# If the directory already exists, just cd into it
2323
[[ -d $target ]] && {
24-
# 显示绿色加粗
24+
# Display in green and bold
2525
print -P "%B[gitcd] $target %F{green}already exists."
2626
cd $target
2727
return
2828
}
2929

3030
git clone $url $target && cd $target
31-
# 显示绿色加粗
31+
# Display in green and bold
3232
print -P "%B%F{green}[gitcd] Done. Have a great day!"
3333
}
3434

3535
_giturl2dir() {
36-
# 规则参考了 https://github.com/repo-utils/giturl/blob/master/lib/giturl.js
36+
# Rules referenced from https://github.com/repo-utils/giturl/blob/master/lib/giturl.js
3737

3838
url=$1
39-
# 删掉 @ 和之前的内容,即 `git@`` || `https://jpillora@` => ""
40-
url=${url#*@} # 删除左端匹配到的内容,最小匹配
41-
# 删掉协议头,即 `git://` || `git+https://` => ""
39+
# Remove `@` and everything before it, e.g., `git@` || `https://jpillora@` => ""
40+
url=${url#*@} # Remove left-matched content, minimal match
41+
# Remove protocol header, e.g., `git://` || `git+https://` => ""
4242
url=${url#*://}
43-
# 删掉末尾的 .git,即 .git => ""
43+
# Remove `.git` at the end, e.g., .git => ""
4444
url=${url%.git*}
45-
# 替换掉第一个冒号,即 github.com:foo/bar => github.com/foo/bar
45+
# Replace the first colon with a slash, e.g., github.com:foo/bar => github.com/foo/bar
4646
url=${url/:/\/}
4747

4848
[[ -n $GITCD_USEHOST ]] && [[ "${GITCD_USEHOST:l}" == "false" ]] && {
4949
# echo $url
5050
url=$(echo $url | cut -d "/" -f 2-)
5151
}
5252

53-
# echo 返回给调用方,而不是用 return
53+
# Return to the caller using echo instead of return
5454
echo $url
55-
}
55+
}

test.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ assert_ok() {
99
}
1010
}
1111

12-
# 规则来自 https://github.com/repo-utils/giturl/blob/master/test/giturl.test.js
12+
# Rules from https://github.com/repo-utils/giturl/blob/master/test/giturl.test.js
1313
assert_ok $(_giturl2dir 'git://gitlab.com/edp/logger.git') 'gitlab.com/edp/logger'
1414
assert_ok $(_giturl2dir 'git@gitlab.com:edp/logger.git') 'gitlab.com/edp/logger'
1515
assert_ok $(_giturl2dir 'git://github.com/treygriffith/cellar.git') 'github.com/treygriffith/cellar'
@@ -44,4 +44,4 @@ assert_ok $(_giturl2dir 'git@github.com:cnpm/cnpm') 'cnpm/cnpm'
4444
assert_ok $(_giturl2dir 'git@gitcafe.com:fengmk2/cnpm.git') 'fengmk2/cnpm'
4545
assert_ok $(_giturl2dir 'git@gist.github.com:3135914.git') '3135914'
4646

47-
print -P "%B%F{green}All Pass!"
47+
print -P "%B%F{green}All Pass!"

0 commit comments

Comments
 (0)