diff --git a/scripts/general.sh b/scripts/general.sh index 1fc6b974d3c7..7fc597b775de 100755 --- a/scripts/general.sh +++ b/scripts/general.sh @@ -362,7 +362,12 @@ fetch_from_github_archive() [[ -n $ref_name ]] || return 1 local base=${upstream_url%.git} - local tar_url="${base}/archive/refs/heads/${ref_name}.tar.gz" + local gh_path=${base#https://github.com/} + local gh_owner=${gh_path%%/*} + local gh_repo=${gh_path#*/} + gh_repo=${gh_repo%%/*} + # Prefer codeload endpoint; it is often more reliable than github.com/archive. + local tar_url="https://codeload.github.com/${gh_owner}/${gh_repo}/tar.gz/refs/heads/${ref_name}" local archive_dir="${EXTER}/cache/sources/.github-archives" local tar_path="${archive_dir}/$(basename "${base}")-${ref_name}.tar.gz" local tar_part="${tar_path}.part"