aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/swap-protocol.bash4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/swap-protocol.bash b/tools/swap-protocol.bash
index 91be977..00b6b4e 100755
--- a/tools/swap-protocol.bash
+++ b/tools/swap-protocol.bash
@@ -1,4 +1,6 @@
1#! /usr/bin/env bash 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
2 4
3target='' 5target=''
4extra='' 6extra=''
@@ -6,7 +8,9 @@ extra=''
6# For each remote 8# For each remote
7git remote -v \ 9git remote -v \
8| while read remote url etc; do 10| while read remote url etc; do
11 # Set fetch/push URL seperately
9 [[ $etc =~ push ]] && extra='--push' || extra='' 12 [[ $etc =~ push ]] && extra='--push' || extra=''
13
10 if [[ $url =~ git@.*github.com ]]; then 14 if [[ $url =~ git@.*github.com ]]; then
11 target=${target:-https} 15 target=${target:-https}
12 [[ $target == https ]] && sed -E 's#^git@(.+):(.+)$#https://\1/\2#' <<<$url | xargs git remote set-url $extra $remote 16 [[ $target == https ]] && sed -E 's#^git@(.+):(.+)$#https://\1/\2#' <<<$url | xargs git remote set-url $extra $remote