Compare commits

...

4 Commits

Author SHA1 Message Date
Ryan Williams
35020b4b21
Merge 22b4bf3fe9 into 99352a64d2 2025-04-09 18:20:15 +05:30
Ryan Williams
22b4bf3fe9 CR: use :- to fallback to origin 2025-03-13 08:40:27 -04:00
Ryan Williams
e82ea42706
CR: env var curly-braces
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2025-03-13 08:39:59 -04:00
Ryan Williams
c54ca7cfa7 install.sh: respect git config --global clone.defaultRemoteName 2025-03-12 23:37:55 -04:00

View File

@ -139,6 +139,9 @@ install_nvm_from_git() {
fi
fi
local remote
remote="$(git config --global clone.defaultRemoteName || true)"
remote="${remote:-origin}"
local fetch_error
if [ -d "$INSTALL_DIR/.git" ]; then
# Updating repo
@ -146,7 +149,7 @@ install_nvm_from_git() {
command printf '\r=> '
fetch_error="Failed to update nvm with $NVM_VERSION, run 'git fetch' in $INSTALL_DIR yourself."
else
fetch_error="Failed to fetch origin with $NVM_VERSION. Please report this!"
fetch_error="Failed to fetch ${remote} with ${NVM_VERSION}. Please report this!"
nvm_echo "=> Downloading nvm from git to '$INSTALL_DIR'"
command printf '\r=> '
mkdir -p "${INSTALL_DIR}"
@ -156,9 +159,9 @@ install_nvm_from_git() {
nvm_echo >&2 'Failed to initialize nvm repo. Please report this!'
exit 2
}
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
nvm_echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
command git --git-dir="${INSTALL_DIR}/.git" remote add "$remote" "$(nvm_source)" 2> /dev/null \
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url "$remote" "$(nvm_source)" || {
nvm_echo >&2 'Failed to add remote "'"$remote"'" (or set the URL). Please report this!'
exit 2
}
else
@ -170,10 +173,10 @@ install_nvm_from_git() {
fi
fi
# Try to fetch tag
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$NVM_VERSION" --depth=1 2>/dev/null; then
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch "$remote" tag "$NVM_VERSION" --depth=1 2>/dev/null; then
:
# Fetch given version
elif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin "$NVM_VERSION" --depth=1; then
elif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch "$remote" "$NVM_VERSION" --depth=1; then
nvm_echo >&2 "$fetch_error"
exit 1
fi