From 1f555b1dd03700893eb460159efc7f03ef9fe2a8 Mon Sep 17 00:00:00 2001
From: Chuck Atkins <chuck.atkins@kitware.com>
Date: Mon, 10 Apr 2017 09:42:11 -0400
Subject: [PATCH] Automatically detect ssh vs https when setting up remotes.

---
 scripts/developer/git/setup-remotes | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/scripts/developer/git/setup-remotes b/scripts/developer/git/setup-remotes
index 107126039..bb4b082c3 100755
--- a/scripts/developer/git/setup-remotes
+++ b/scripts/developer/git/setup-remotes
@@ -17,20 +17,16 @@ then
   exit 1
 fi
 git remote set-url origin https://github.com/${GH_USERNAME}/adios2.git
-read -p "Setup SSH push access? [(y)/n] " GH_USE_SSH
-GH_USE_SSH="${GH_USE_SSH,,}"
-if [ -z "${GH_USE_SSH}" ]
-then
-  echo "  Empty entry.  Using 'y' as default"
-  GH_USE_SSH="y"
-elif [ "${GH_USE_SSH}" != "y" ] && [ "${GH_USE_SSH}" != "n" ]
-then
-  echo "  Invalid entry.  Using 'y' by default"
-  GH_USE_SSH="y"
-fi
-if [ "${GH_USE_SSH}" == "y" ]
+
+echo "Testing SSH access to GitHub..."
+ssh -T git@github.com 2>/dev/null
+if [ $? -eq 1 ]
 then
+  echo "Success!  Setting up SSH push access to your fork."
   git config remote.origin.pushurl "git@github.com:${GH_USERNAME}/adios2.git"
+else
+  echo "SSH access failed.  Setting up HTTPS push access instead"
+  git config remote.origin.pushurl https://${GH_USERNAME}@github.com/${GH_USERNAME}/adios2.git
 fi
 
 
-- 
GitLab