diff options
author | typebrook <typebrook@gmail.com> | 2020-03-13 15:17:25 +0800 |
---|---|---|
committer | typebrook <typebrook@gmail.com> | 2020-03-13 15:27:03 +0800 |
commit | 299c28943077b14d42938c2ade009a1647acde14 (patch) | |
tree | a9903a35d7d63ed0a9e15b4f788ea78228f7c2cc | |
parent | a9139a8c5e7158cd96809cd0ae62e3a1ca56b5d6 (diff) |
Change remote url if user configure protocol
-rwxr-xr-x | gist | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -587,6 +587,19 @@ usage() { | |||
587 | sed -E -n -e ' /^$/ q; 7,$ s/^# //p' "$0" | 587 | sed -E -n -e ' /^$/ q; 7,$ s/^# //p' "$0" |
588 | } | 588 | } |
589 | 589 | ||
590 | _check_protocol() { | ||
591 | find $folder -maxdepth 1 -mindepth 1 -type d \ | ||
592 | | while read -r repo; do | ||
593 | cd "$repo" || exit 1 | ||
594 | url=$(git remote get-url origin) | ||
595 | if [[ $protocol == 'ssh' && $url =~ ^https ]]; then | ||
596 | git remote set-url origin "git@gist.github.com:$(basename `pwd`).git" | ||
597 | elif [[ $protocol == 'https' && $url =~ ^git ]]; then | ||
598 | git remote set-url origin "https://gist.github.com/$(basename `pwd`).git" | ||
599 | fi | ||
600 | done | ||
601 | } | ||
602 | |||
590 | _apply_config "$@" || exit 1 | 603 | _apply_config "$@" || exit 1 |
591 | getConfiguredClient || exit 1 | 604 | getConfiguredClient || exit 1 |
592 | if [[ $init ]]; then _fetch_gists; exit 0; fi | 605 | if [[ $init ]]; then _fetch_gists; exit 0; fi |
@@ -615,7 +628,7 @@ case "$1" in | |||
615 | _clean_repos ;; | 628 | _clean_repos ;; |
616 | config | c) | 629 | config | c) |
617 | shift | 630 | shift |
618 | _configure "$@" ;; | 631 | _configure "$@" && (_apply_config config && _check_protocol) ;; |
619 | user | U) | 632 | user | U) |
620 | shift | 633 | shift |
621 | _query_user "$@" ;; | 634 | _query_user "$@" ;; |