aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortypebrook <typebrook@gmail.com>2020-03-13 15:17:25 +0800
committertypebrook <typebrook@gmail.com>2020-03-13 15:27:03 +0800
commit299c28943077b14d42938c2ade009a1647acde14 (patch)
treea9903a35d7d63ed0a9e15b4f788ea78228f7c2cc
parenta9139a8c5e7158cd96809cd0ae62e3a1ca56b5d6 (diff)
Change remote url if user configure protocol
-rwxr-xr-xgist15
1 files changed, 14 insertions, 1 deletions
diff --git a/gist b/gist
index 57a6d04..6b1776e 100755
--- a/gist
+++ b/gist
@@ -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
591getConfiguredClient || exit 1 604getConfiguredClient || exit 1
592if [[ $init ]]; then _fetch_gists; exit 0; fi 605if [[ $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 "$@" ;;