From a595e7c066c9b2700e5323f41f0a6af8eea68887 Mon Sep 17 00:00:00 2001 From: typebrook Date: Mon, 4 May 2020 09:59:50 +0800 Subject: update --- tools/swap-protocol.bash | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/swap-protocol.bash') 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 @@ #! /usr/bin/env bash +# Get the first remote URL within git/https protocol on github.com +# Swap the protocol, and apply new protocol to every remaining remotes target='' extra='' @@ -6,7 +8,9 @@ extra='' # For each remote git remote -v \ | while read remote url etc; do + # Set fetch/push URL seperately [[ $etc =~ push ]] && extra='--push' || extra='' + if [[ $url =~ git@.*github.com ]]; then target=${target:-https} [[ $target == https ]] && sed -E 's#^git@(.+):(.+)$#https://\1/\2#' <<<$url | xargs git remote set-url $extra $remote -- cgit v1.2.3-70-g09d2