解决一些p0问题

This commit is contained in:
2026-08-13 09:31:12 +08:00
parent ea61505472
commit d693318a02
32 changed files with 608 additions and 949 deletions
+13 -39
View File
@@ -304,61 +304,35 @@ ensure_repo_version() {
local ver="$3"
repo_dir="${_git_cache_dir_}/${dep}"
local urls=()
log_info "ensure_repo_version ${dep} ${ver}"
get_git_urls "$dep" urls || return 1
get_git_urls "$dep" urls || exit $?
local repo_url="${urls[0]}"
# CHECK_REPO
# CHECK_LOCAL
log_info "检查是否需要克隆"
if [[ ! -d "$repo_dir/.git" ]]; then
log_info "克隆仓库: $repo_url$repo_dir"
if ! exec_record "git clone --origin origin \"$repo_url\" \"$repo_dir\" "; then
log_error "clone 失败"
return 1
fi
exec_record_fast_fail "git clone --origin origin \"$repo_url\" \"$repo_dir\" "
fi
# CHECK_LOCAL
log_info "测试本地是否有版本"
if repo_has_ver_local "$repo_dir" "$ver"; then
log_info "checkout $ver"
exec_record "git -C \"$repo_dir\" checkout \"$ver\" " || {
log_error "checkout 失败"
return 1
}
exec_record_fast_fail "git -C \"$repo_dir\" checkout \"$ver\" "
return 0
fi
# FETCH
log_info "fetch 更新仓库"
if ! exec_record "git -C \"$repo_dir\" fetch --tags origin"; then
log_error "fetch 失败"
return 1
fi
if repo_has_ver_remote "$repo_dir" "${ver}"; then
:
else
log_error "远端仓库不存在版本: $ver"
print_repo_refs_remote "$repo_dir"
#exec_record " git ls-remote ${repo_url}"
return 3
fi
# CHECK_LOCAL AGAIN
exec_record_fast_fail "git -C \"$repo_dir\" fetch --tags origin"
if repo_has_ver_local "$repo_dir" "$ver"; then
log_info "checkout $ver"
exec_record "git -C \"$repo_dir\" checkout \"$ver\" " || {
log_error "checkout 失败"
return 1
}
exec_record_fast_fail "git -C \"$repo_dir\" checkout \"$ver\" "
return 0
fi
return 0
if git -C "$repo_dir" show-ref --verify --quiet "refs/remotes/origin/$ver"; then
log_info "checkout branch $ver"
exec_record_fast_fail "git -C \"$repo_dir\" checkout -B \"$ver\" \"origin/$ver\" "
return 0
fi
log_error "远端仓库不存在版本: $ver"
print_repo_refs_remote "$repo_url"
exit 3
}
#configure_git_repo(){