6ef236dd99f2090b54911f9135d00ac37d6757ff

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(updater): search for upstream remote if using non-conventional name (#11135)

Fixes #11135

Diff

 1diff --git a/tools/upgrade.sh b/tools/upgrade.sh
 2index d9a372d137a98190616a9c9a4a053d2476b8d5c1..34ff3f027f8547ece2d7cf880bce56aafdf28056 100755
 3--- a/tools/upgrade.sh
 4+++ b/tools/upgrade.sh
 5@@ -1,5 +1,7 @@
 6 #!/usr/bin/env zsh
 7 
 8+local ret=0 # exit code
 9+
10 # Protect against running with shells other than zsh
11 if [ -z "$ZSH_VERSION" ]; then
12   exec zsh "$0" "$@"
13@@ -181,17 +183,23 @@ fi
14 # Update upstream remote to ohmyzsh org
15 git remote -v | while read remote url extra; do
16   case "$url" in
17+  git://github.com/robbyrussell/oh-my-zsh(|.git))
18+    # Update out-of-date "unauthenticated git protocol on port 9418" to https
19+    git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git" ;;
20   https://github.com/robbyrussell/oh-my-zsh(|.git))
21-    git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
22-    break ;;
23+    git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git" ;;
24   git@github.com:robbyrussell/oh-my-zsh(|.git))
25-    git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git"
26-    break ;;
27-  # Update out-of-date "unauthenticated git protocol on port 9418" to https
28-  git://github.com/robbyrussell/oh-my-zsh(|.git))
29-    git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
30-    break ;;
31+    git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git" ;;
32+  https://github.com/ohmyzsh/ohmyzsh(|.git)) ;;
33+  git@github.com:ohmyzsh/ohmyzsh(|.git)) ;;
34+  *) continue ;;
35   esac
36+
37+  # If we reach this point we have found the proper ohmyzsh upstream remote. If we don't,
38+  # we'll only update from the set remote if `oh-my-zsh.remote` has been set to a remote,
39+  # as when installing from a fork.
40+  git config --local oh-my-zsh.remote "$remote"
41+  break
42 done
43 
44 # Set git-config values known to fix git errors