代码拉取完成,页面将自动刷新
同步操作将从 乐鑫开源/esp-gitee-tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash
#
# Redirects git submodules to gitee mirrors and updates these recursively.
#
# To revert the changed URLs use 'git submodule deinit .'
#
# -----------------------------------------------------------------------------
# Common bash
if [[ ! -z ${DEBUG_SHELL} ]]
then
set -x # Activate the expand mode if DEBUG is anything but empty.
fi
set -o errexit # Exit if command failed.
set -o pipefail # Exit if pipe failed.
set -o nounset # Exit if variable not set.
die() {
echo "${1:-"Unknown Error"}" 1>&2
exit 1
}
check_git_version() {
currentver="$(echo $(git --version 2>&1 |awk 'NR==1{gsub(/"/,"");print $3}'))"
requiredver="2.11.0"
if [ "$(printf '%s\n' "$requiredver" "$currentver" | sort -V | head -n1)" = "$requiredver" ]; then
# Greater than or equal to 2.11.0
true
else
# Less than 2.11.0
false
fi
}
# -----------------------------------------------------------------------------
ERR_CANNOT_UPDATE=13
REPO_DIR=${1:-"${PWD}"}
REPO_DIR=$(cd ${REPO_DIR} && pwd -P)
SCRIPT_SH=$(cd "$(dirname "${0}")" && pwd -P)/$(basename "${0}")
[ -d "${REPO_DIR}" ] || die "${REPO_DIR} is not directory!"
[ -f "${SCRIPT_SH}" ] || die "${SCRIPT_SH} does not exist!"
## repo group
REPOS_ARRAY=(
esp-idf espressifsystems
esp-rainmaker espressifsystems
esp-insights espressifsystems
esp-qcloud espressifsystems
esp-sr esp-components
esp-adf-libs esp-components
esp32-camera esp-components
esp-rainmaker-common esp-components
esp-dl esp-components
)
len=${#REPOS_ARRAY[@]}
pushd ${REPO_DIR} >/dev/null
# 0
[ -f ".gitmodules" ] || exit 0
# 1
git submodule init
# 2
# Replacing each submodule URL of the current repository
# to the mirror repos in gitee
for LINE in $(git config -f .gitmodules --list | grep "\.url=../[^.]\|\.url=../../[^.]\|\.url=https://github.com/[^.]\|\.url=https://git.eclipse.org/[^.]")
do
SUBPATH=$(echo "${LINE}" | sed "s|^submodule\.\([^.]*\)\.url.*$|\1|")
LOCATION=$(echo "${LINE}" | sed 's/.*\///' | sed 's/.git//g' | sed 's/.*\.//')
for ((i=0;i<len;i+=2))
do
REPO=${REPOS_ARRAY[i]}
GROUP=${REPOS_ARRAY[i+1]}
if [ "$LOCATION" = "$REPO" ]; then
SUBURL="https://gitee.com/$GROUP/$LOCATION"
break
else
# gitee url is case sensitive
if [ "$LOCATION" = "unity" ]; then
LOCATION="Unity"
fi
if [ "$LOCATION" = "cexception" ]; then
LOCATION="CException"
fi
SUBURL="https://gitee.com/esp-submodules/$LOCATION"
fi
done
git config submodule."${SUBPATH}".url "${SUBURL}"
done
# 3
# Getting submodules of the current repository from gitee mirrors
if check_git_version; then
git submodule update --progress || exit $ERR_CANNOT_UPDATE
else
git submodule update || exit $ERR_CANNOT_UPDAT
fi
# 4
# Replacing URLs for each sub-submodule.
# The script runs recursively
git submodule foreach "${SCRIPT_SH}" # No '--recursive'
popd >/dev/null
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。