|
6 | 6 | usage_import()
|
7 | 7 | {
|
8 | 8 | cat <<\USAGE_import_EOF
|
9 | | -gi import usage: git issue import provider user repo |
| 9 | +gi import usage: git issue import [remote | provider user repo] |
10 | 10 | Example: git issue import github torvalds linux
|
11 | 11 | USAGE_import_EOF
|
12 | 12 | exit 2
|
@@ -883,16 +883,51 @@ t again
|
883 | 883 | ' "1ドル"-header
|
884 | 884 | }
|
885 | 885 |
|
| 886 | +# Returns the git's repository URL |
| 887 | +get_url() |
| 888 | +{ |
| 889 | + local remote=1ドル |
| 890 | + |
| 891 | + if [ -z "${remote}" ] |
| 892 | + then |
| 893 | + remote="origin" |
| 894 | + fi |
| 895 | + |
| 896 | + git remote get-url ${remote} 2>&1 |
| 897 | +} |
| 898 | + |
| 899 | +# Returns the git's repository provider name from the URL |
| 900 | +get_provider() |
| 901 | +{ |
| 902 | + echo "1ドル" | sed "s|^git@||; s|^https://||; s|/[a-z]*||; s|.com.*||" |
| 903 | +} |
| 904 | +# Returns the git's repository user name from the URL |
| 905 | +get_user() |
| 906 | +{ |
| 907 | + echo "1ドル" | sed -E "s/.*\.com[:|/]([^/]*).*/1円/" |
| 908 | +} |
| 909 | +# Returns the git's repository repo name from the URL |
| 910 | +get_repo() |
| 911 | +{ |
| 912 | + echo "1ドル" | sed -E "s/.*\.com[:|/].*\/([^.]*).git/1円/" |
| 913 | +} |
| 914 | + |
886 | 915 | # Import issues from specified source (currently github and gitlab)
|
887 | 916 | sub_import()
|
888 | 917 | {
|
889 | | - local endpoint user repo begin_sha provider |
| 918 | + local endpoint user repo begin_sha provider url |
890 | 919 |
|
891 | | - test "1ドル" = github -o "1ドル" = gitlab -a -n "2ドル" -a -n "3ドル" || usage_import |
892 | | - provider="1ドル" |
893 | | - # convert to lowercase to avoid duplicates |
894 | | - user="$(convert_to_lower_case "2ドル")" |
895 | | - repo="$(convert_to_lower_case "3ドル")" |
| 920 | + test "1ドル" = github -o "1ドル" = gitlab -a -n "2ドル" -a -n "3ドル" || |
| 921 | + url=$(get_url "1ドル"); if [ "${url}" = "fatal: No such remote '${1}'" ]; then printf "%s\n\n" "${url}"; usage_import; fi; provider=$(get_provider "${url}"); user=$(get_user "${url}"); repo=$(get_repo "${url}") |
| 922 | + |
| 923 | + if ! test -n "${provider}" && ! test -n "${user}" && ! test -n "${repo}" |
| 924 | + then |
| 925 | + provider="1ドル" |
| 926 | + |
| 927 | + # convert to lowercase to avoid duplicates |
| 928 | + user="$(convert_to_lower_case "2ドル")" |
| 929 | + repo="$(convert_to_lower_case "3ドル")" |
| 930 | + fi |
896 | 931 |
|
897 | 932 | cdissues
|
898 | 933 |
|
|
0 commit comments