From c54ca7cfa737a2fb0ec62dd0f3eb49715b639c25 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Wed, 12 Mar 2025 23:28:04 -0400 Subject: [PATCH 1/3] `install.sh`: respect `git config --global clone.defaultRemoteName` --- install.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 79ae3b1..2868cca 100755 --- a/install.sh +++ b/install.sh @@ -139,6 +139,11 @@ install_nvm_from_git() { fi fi + local remote + remote="$(git config --global clone.defaultRemoteName || true)" + if [ -z "$remote" ]; then + remote=origin + fi local fetch_error if [ -d "$INSTALL_DIR/.git" ]; then # Updating repo @@ -146,7 +151,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 +161,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 +175,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 From e82ea4270672ba154e5ce49ff2e80c08f0f1a368 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Thu, 13 Mar 2025 08:39:59 -0400 Subject: [PATCH 2/3] CR: env var curly-braces Co-authored-by: Jordan Harband --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 2868cca..918172e 100755 --- a/install.sh +++ b/install.sh @@ -151,7 +151,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 $remote 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}" From 22b4bf3fe94cd5ca43c4227d9f10c38eecec30e9 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Thu, 13 Mar 2025 08:36:42 -0400 Subject: [PATCH 3/3] CR: use `:-` to fallback to `origin` --- install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 918172e..dc9c3e5 100755 --- a/install.sh +++ b/install.sh @@ -141,9 +141,7 @@ install_nvm_from_git() { local remote remote="$(git config --global clone.defaultRemoteName || true)" - if [ -z "$remote" ]; then - remote=origin - fi + remote="${remote:-origin}" local fetch_error if [ -d "$INSTALL_DIR/.git" ]; then # Updating repo