移除默认github代理,增加http或者socks代理参数

This commit is contained in:
whyour
2022-01-19 23:29:55 +08:00
parent 5b6843b5c0
commit 8c0685202e
4 changed files with 30 additions and 16 deletions
+21 -1
View File
@@ -67,7 +67,7 @@ import_config() {
[[ -f $file_env ]] && . $file_env
command_timeout_time=${CommandTimeoutTime:-"1h"}
github_proxy_url=${GithubProxyUrl:-""}
proxy_url=${ProxyUrl:-""}
file_extensions=${RepoFileExtensions:-"js py"}
if [[ -n "${DefaultCronRule}" ]]; then
@@ -77,6 +77,18 @@ import_config() {
fi
}
set_proxy() {
if [[ $proxy_url ]]; then
export http_proxy="${proxy_url}"
export https_proxy="${proxy_url}"
fi
}
unset_proxy() {
unset http_proxy
unset https_proxy
}
make_dir() {
local dir=$1
if [[ ! -d $dir ]]; then
@@ -287,7 +299,11 @@ git_clone_scripts() {
local branch=$3
[[ $branch ]] && local part_cmd="-b $branch "
echo -e "开始克隆仓库 $url$dir\n"
set_proxy
git clone $part_cmd $url $dir
unset_proxy
exit_status=$?
}
@@ -298,10 +314,14 @@ git_pull_scripts() {
[[ $branch ]] && local part_cmd="origin/${branch}"
cd $dir_work
echo -e "开始更新仓库:$dir_work\n"
set_proxy
git fetch --all
exit_status=$?
git reset --hard $part_cmd
git pull
unset_proxy
cd $dir_current
}