aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-05-04 09:59:50 +0800
committertypebrook <typebrook@gmail.com>2020-05-04 09:59:50 +0800
commita595e7c066c9b2700e5323f41f0a6af8eea68887 (patch)
tree242b012762389dd75b9e8440fb2f189037ff37fd
parentca9acdbd6757ab87530df0cddfca982fc57e7fcb (diff)
update
-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