[Fix] when originally installed without git, ensure it can be upgraded to use git.
Fixes #1212. Closes #1213.
parent
7e18328a88
commit
68bf93514b
28
install.sh
28
install.sh
|
@ -78,13 +78,29 @@ install_nvm_from_git() {
|
||||||
# Cloning to $INSTALL_DIR
|
# Cloning to $INSTALL_DIR
|
||||||
echo "=> Downloading nvm from git to '$INSTALL_DIR'"
|
echo "=> Downloading nvm from git to '$INSTALL_DIR'"
|
||||||
command printf "\r=> "
|
command printf "\r=> "
|
||||||
mkdir -p "$INSTALL_DIR"
|
mkdir -p "${INSTALL_DIR}"
|
||||||
command git clone "$(nvm_source)" "$INSTALL_DIR" || {
|
if [ "$(ls -A "${INSTALL_DIR}")" ]; then
|
||||||
echo >&2 "Failed to clone nvm repo. Please report this!"
|
command git init "${INSTALL_DIR}" || {
|
||||||
exit 1
|
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)" || {
|
||||||
|
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
command git --git-dir="${INSTALL_DIR}/.git" fetch origin --tags || {
|
||||||
|
echo >&2 'Failed to fetch origin with tags. Please report this!'
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
else
|
||||||
|
command git clone "$(nvm_source)" "${INSTALL_DIR}" || {
|
||||||
|
echo >&2 'Failed to clone nvm repo. Please report this!'
|
||||||
|
exit 2
|
||||||
|
}
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout --quiet "$(nvm_latest_version)"
|
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout -f --quiet "$(nvm_latest_version)"
|
||||||
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
|
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then
|
||||||
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
|
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet 2>/dev/null; then
|
||||||
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
|
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" branch --quiet -D master >/dev/null 2>&1
|
||||||
|
|
Loading…
Reference in New Issue