[update.sh] Parse local token in git remote.origin.url config
This commit is contained in:
parent
a783aaf03f
commit
c83172c8f4
@ -513,12 +513,12 @@ EOS
|
||||
|
||||
# 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
|
||||
#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
|
||||
lock update
|
||||
@ -637,12 +637,36 @@ EOS
|
||||
# the refspec ensures that the default upstream branch gets updated
|
||||
(
|
||||
UPSTREAM_REPOSITORY_URL="$(git config remote.origin.url)"
|
||||
UPSTREAM_REPOSITORY_TOPARSE="${UPSTREAM_REPOSITORY_URL#*://}"
|
||||
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.
|
||||
# UPSTREAM_REPOSITORY_TOKEN is optionally defined in the git configuration and will try to supersede
|
||||
# shellcheck disable=SC2153
|
||||
if [[ -n "${UPSTREAM_REPOSITORY_TOKEN}" ]]
|
||||
then
|
||||
CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${UPSTREAM_REPOSITORY_TOKEN}")
|
||||
elif [[ -n "${HOMEBREW_GITHUB_API_TOKEN}" ]]
|
||||
then
|
||||
CURL_GITHUB_API_ARGS=("--header" "Authorization: token ${HOMEBREW_GITHUB_API_TOKEN}")
|
||||
else
|
||||
CURL_GITHUB_API_ARGS=()
|
||||
fi
|
||||
|
||||
# HOMEBREW_UPDATE_FORCE and HOMEBREW_UPDATE_AUTO aren't modified here so ignore subshell warning.
|
||||
# shellcheck disable=SC2030
|
||||
if [[ "${UPSTREAM_REPOSITORY_URL}" == "https://github.com/"* ]]
|
||||
if [[ "${UPSTREAM_REPOSITORY_URL}" == "https://github.com/"* ]] \
|
||||
|| [[ "${UPSTREAM_REPOSITORY_DOMAIN%:*}" == "github.com" ]]
|
||||
then
|
||||
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}"
|
||||
#UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_URL#https://github.com/}"
|
||||
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY_TOPARSE#*/}"
|
||||
UPSTREAM_REPOSITORY="${UPSTREAM_REPOSITORY%.git}"
|
||||
|
||||
if [[ "${DIR}" == "${HOMEBREW_REPOSITORY}" && -n "${HOMEBREW_UPDATE_TO_TAG}" ]]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user