aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/swap-protocol.bash
diff options
context:
space:
mode:
Diffstat (limited to 'tools/swap-protocol.bash')
-rwxr-xr-xtools/swap-protocol.bash25
1 files changed, 0 insertions, 25 deletions
diff --git a/tools/swap-protocol.bash b/tools/swap-protocol.bash
deleted file mode 100755
index b7f4db2..0000000
--- a/tools/swap-protocol.bash
+++ /dev/null
@@ -1,25 +0,0 @@
1#! /usr/bin/env bash
2# Get the first remote URL within git/https protocol on github.com
3# Swap the protocol, and apply new protocol to every remaining remotes
4
5target=''
6extra=''
7
8# For each remote
9git remote -v \
10| while read remote url etc; do
11 # Set fetch/push URL seperately
12 [[ $etc =~ push ]] && extra='--push' || extra=''
13
14 if [[ $url =~ git@.*github.com ]]; then
15 target=${target:-https}
16 # git@ -> https://
17 [[ $target == https ]] && sed -E 's#^git@(.+):(.+)$#https://\1/\2#' <<<$url | xargs git remote set-url $extra $remote
18 elif [[ $url =~ https://.*github.com ]]; then
19 target=${target:-git}
20 # https:// -> git@
21 [[ $target == git ]] && sed -E 's#^https://([^/]+)/(.+)$#git@\1:\2#' <<<$url | xargs git remote set-url $extra $remote
22 fi
23done
24
25git remote -v