Release Candidate 1

This commit is contained in:
Sharon Azriel 2023-12-06 14:20:54 +02:00
parent c83172c8f4
commit e24027ea57
2 changed files with 60 additions and 25 deletions

View File

@ -18,6 +18,7 @@
# HOMEBREW_USER_AGENT_CURL are set by brew.sh # HOMEBREW_USER_AGENT_CURL are set by brew.sh
# shellcheck disable=SC2154 # shellcheck disable=SC2154
source "${HOMEBREW_LIBRARY}/Homebrew/utils/lock.sh" source "${HOMEBREW_LIBRARY}/Homebrew/utils/lock.sh"
source "${HOMEBREW_LIBRARY}/Homebrew/utils/url.sh"
# Replaces the function in Library/Homebrew/brew.sh to cache the Curl/Git executable to # Replaces the function in Library/Homebrew/brew.sh to cache the Curl/Git executable to
# provide speedup when using Curl/Git repeatedly (as update.sh does). # provide speedup when using Curl/Git repeatedly (as update.sh does).
@ -511,15 +512,6 @@ EOS
CURL_DISABLE_CURLRC_ARGS=() CURL_DISABLE_CURLRC_ARGS=()
fi fi
# HOMEBREW_GITHUB_API_TOKEN is optionally defined in the user environment.
# shellcheck disable=SC2153
#if [[ -n "${HOMEBREW_GITHUB_API_TOKEN}" ]]
#then
# CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${HOMEBREW_GITHUB_API_TOKEN}")
#else
# CURL_GITHUB_API_ARGS=()
#fi
# only allow one instance of brew update # only allow one instance of brew update
lock update lock update
@ -637,22 +629,14 @@ EOS
# the refspec ensures that the default upstream branch gets updated # the refspec ensures that the default upstream branch gets updated
( (
UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)" UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)"
UPSTREAM_REPOSITORY_TOPARSE="${UPSTREAM_REPOSITORY_URL#*://}" UPSTREAM_REPOSITORY_URL_PARSED=( $(url_get "${UPSTREAM_REPOSITORY_URL}" user pass host path) )
UPSTREAM_REPOSITORY_L1="${UPSTREAM_REPOSITORY_TOPARSE%%/*}"
UPSTREAM_REPOSITORY_DOMAIN="${UPSTREAM_REPOSITORY_L1#*@}"
[[ "${UPSTREAM_REPOSITORY_L1}" == "${UPSTREAM_REPOSITORY_DOMAIN}" ]] \
&& UPSTREAM_REPOSITORY_USERPASS="" \
|| UPSTREAM_REPOSITORY_USERPASS="${UPSTREAM_REPOSITORY_L1%@*}"
[[ -z "${UPSTREAM_REPOSITORY_USERPASS%:*}" ]] || [[ "${UPSTREAM_REPOSITORY_USERPASS%:*}" == "git" ]] \
&& UPSTREAM_REPOSITORY_TOKEN="" \
|| UPSTREAM_REPOSITORY_TOKEN="${UPSTREAM_REPOSITORY_USERPASS#*:}"
# HOMEBREW_GITHUB_API_TOKEN is optionally defined in the user environment. # HOMEBREW_GITHUB_API_TOKEN is optionally defined in the user environment.
# UPSTREAM_REPOSITORY_TOKEN is optionally defined in the git configuration and will try to supersede # can be supersede by local repository URL
# shellcheck disable=SC2153 # shellcheck disable=SC2153
if [[ -n "${UPSTREAM_REPOSITORY_TOKEN}" ]] if [[ -n "${UPSTREAM_REPOSITORY_URL_PARSED[1]}" ]]
then then
CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${UPSTREAM_REPOSITORY_TOKEN}") CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${UPSTREAM_REPOSITORY_URL_PARSED[1]}")
elif [[ -n "${HOMEBREW_GITHUB_API_TOKEN}" ]] elif [[ -n "${HOMEBREW_GITHUB_API_TOKEN}" ]]
then then
CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${HOMEBREW_GITHUB_API_TOKEN}") CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${HOMEBREW_GITHUB_API_TOKEN}")
@ -663,11 +647,9 @@ EOS
# HOMEBREW_UPDATE_FORCE and HOMEBREW_UPDATE_AUTO aren't modified here so ignore subshell warning. # HOMEBREW_UPDATE_FORCE and HOMEBREW_UPDATE_AUTO aren't modified here so ignore subshell warning.
# shellcheck disable=SC2030 # shellcheck disable=SC2030
if [[ "${UPSTREAM_REPOSITORY_URL}" == "https://github.com/"* ]] \ if [[ "${UPSTREAM_REPOSITORY_URL}" == "https://github.com/"* ]] \
|| [[ "${UPSTREAM_REPOSITORY_DOMAIN%:*}" == "github.com" ]] || [[ "${UPSTREAM_REPOSITORY_URL_PARSED[2]}" == "github.com" ]]
then then
#UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}" UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL_PARSED[3]%.git}"
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_TOPARSE#*/}"
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}"
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]] if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
then then

53
Library/Homebrew/utils/url.sh Executable file
View File

@ -0,0 +1,53 @@
# url_get <URL> [key] [key] ...
# where:
# URL ~ [scheme://][user[:pass]@]host[:port][path]
# key is one of the element composing the URL
url_get() {
[[ ${#} -gt 0 ]] || return
local url="${1}"
[[ -z "${url}" ]] && return
shift
local _uphpp="${url#*://}"
local _scheme="${url%%://*}"
if [[ "${url}" == "${_uphpp}" ]]; then
_scheme=""
fi
local _hpp="${_uphpp#*@}"
local _up="${_uphpp%%@*}"
if [[ "${_uphpp}" == "${_hpp}" ]]; then
local _user=""
local _pass=""
else
local _user="${_up%:*}"
local _pass="${_up#*:}"
if [[ "${_user}" == "${_up}" ]]; then
_pass=""
fi
fi
local _hp="${_hpp%%/*}"
# TODO: split path from arguments (path?arg=...&....)
local _path="${_hpp#*/}"
if [[ "${_hp}" == "${_hpp}" ]]; then
_path=""
elif [[ -z "${_path}" ]]; then
_path="/"
fi
local _host="${_hp%:*}"
local _port="${_hp#*:}"
if [[ "${_hp}" == "${_host}" ]]; then
_port=""
fi
while [[ ${#} -gt 0 ]]; do
echo -n "$(eval echo -n "\${_${1}}")"
[[ ${#} -gt 1 ]] && echo -n ${IFS}
shift
done
}
# EoF