summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNathaniel Graff <nathaniel.graff@sifive.com>2019-04-19 18:05:52 +0000
committerGitHub <noreply@github.com>2019-04-19 18:05:52 +0000
commita351dc8d6aaf1a10be9a08e66c78c37126833d6a (patch)
treeae2ea1c6154727b2ac774b94518b51947e50e6db /scripts
parent41b5a7fa29179221628abc340bdaa67fb7704a6f (diff)
parent8bd9b37f86eb5a29e90ac74520cffdf1c572fce0 (diff)
Merge pull request #237 from sifive/submodule-urls-script
Add script to update submodule URLs to use SSH
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/submodules-use-ssh.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/submodules-use-ssh.sh b/scripts/submodules-use-ssh.sh
new file mode 100755
index 0000000..25a270d
--- /dev/null
+++ b/scripts/submodules-use-ssh.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env sh
+
+# By default, when you clone Freedom E SDK, submodules are instantiated with their
+# origin URLs pointing to GitHub's HTTPS URL for the repository.
+
+# If you're a collaborator of this repository, it's annoying to update all the
+# submodule URLs so that you can push to the repositories. This script fixes that
+# by changing all the submodules to use SSH instead of HTTPS. If you're not a
+# collaborator, don't bother using this script unless you really want to authenticate
+# to GitHub with SSH for some reason.
+
+set -e
+set -o pipefail
+
+SUBMODULE_PATHS=`grep -o "path = .*$" .gitmodules | cut -d ' ' -f 3`
+
+for SUBMODULE in $SUBMODULE_PATHS ; do
+ pushd $SUBMODULE > /dev/null
+
+ OLD_URL=`git remote get-url origin`
+
+ NEW_URL=`echo $OLD_URL | sed -e 's/https:\/\/github.com\//git@github.com:/'`
+
+ echo "Updating URL for $SUBMODULE from $OLD_URL to $NEW_URL"
+
+ git remote set-url origin $NEW_URL
+
+ popd > /dev/null
+done
+