Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5163845

Browse files
author
Frazer C
committed
feat(import/export): simplify git issue import and export functionality
Allow git issue import to work without arguments by fetching the information from $(git remote get-url ${remote}). But also allow just the remote to be defined if 1 arguement is present while preserving the previous functionality, for repos that may have separate issue trackers in forked repos.
1 parent a281489 commit 5163845

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

‎lib/git-issue/import-export.sh

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
usage_import()
77
{
88
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]
1010
Example: git issue import github torvalds linux
1111
USAGE_import_EOF
1212
exit 2
@@ -883,16 +883,51 @@ t again
883883
' "1ドル"-header
884884
}
885885

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+
886915
# Import issues from specified source (currently github and gitlab)
887916
sub_import()
888917
{
889-
local endpoint user repo begin_sha provider
918+
local endpoint user repo begin_sha provider url
890919

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
896931

897932
cdissues
898933

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /