diff options
Diffstat (limited to 'tools/swap-protocol.bash')
-rwxr-xr-x | tools/swap-protocol.bash | 11 |
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 @@ | |||
3 | target='' | 3 | target='' |
4 | extra='' | 4 | extra='' |
5 | 5 | ||
6 | # For each remote | ||
6 | git remote -v \ | 7 | git 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 |
16 | done | 17 | done |
17 | 18 | ||