aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/swap-protocol.bash
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-05-04 09:55:34 +0800
committertypebrook <typebrook@gmail.com>2020-05-04 09:55:34 +0800
commitca9acdbd6757ab87530df0cddfca982fc57e7fcb (patch)
tree3168394cf865dcaf418a1b84dd15b1c7af723a77 /tools/swap-protocol.bash
parent4cf08e6c9a9462b9b4544ce0589880fd56e0aa94 (diff)
update
Diffstat (limited to 'tools/swap-protocol.bash')
-rwxr-xr-xtools/swap-protocol.bash11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/swap-protocol.bash b/tools/swap-protocol.bash
index a70e7fe..91be977 100755
--- a/tools/swap-protocol.bash
+++ b/tools/swap-protocol.bash
@@ -3,15 +3,16 @@
3target='' 3target=''
4extra='' 4extra=''
5 5
6# For each remote
6git remote -v \ 7git remote -v \
7| while read remote url etc; do 8| while read remote url etc; do
8 [[ $etc =~ push ]] && extra='--push' 9 [[ $etc =~ push ]] && extra='--push' || extra=''
9 if [[ -z $target || $target == https ]] && [[ $url =~ git@.*github.com ]]; then 10 if [[ $url =~ git@.*github.com ]]; then
10 target=${target:-https} 11 target=${target:-https}
11 sed -E 's#git@(.+):(.+)#https://\1/\2#' <<<$url | xargs git remote set-url $extra $remote 12 [[ $target == https ]] && sed -E 's#^git@(.+):(.+)$#https://\1/\2#' <<<$url | xargs git remote set-url $extra $remote
12 elif [[ -z $target || $target == git ]] && [[ $url =~ https://.*github.com ]]; then 13 elif [[ $url =~ https://.*github.com ]]; then
13 target=${target:-git} 14 target=${target:-git}
14 sed -E 's#https://([^/]+)/(.+)#git@\1:\2#' <<<$url | xargs git remote set-url $extra $remote 15 [[ $target == git ]] && sed -E 's#^https://([^/]+)/(.+)$#git@\1:\2#' <<<$url | xargs git remote set-url $extra $remote
15 fi 16 fi
16done 17done
17 18