Last active
December 26, 2022 07:17
-
-
Save hayeah/8dcce661f0461d071147ebdb829a76a9 to your computer and use it in GitHub Desktop.
Revisions
-
hayeah revised this gist
Dec 26, 2022 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,9 +33,7 @@ gclone() { url="$url.git" fi # If a clone destination was not specified as the second argument, extract it from the URL if [ -z "$2" ]; then repo_name=$(echo "$1" | sed -E 's/.*\/([^/]+\/[^/]+).*/\1/') else -
hayeah created this gist
Dec 26, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ : <<COMMENT # Clone the repository with the default repository name gclone https://github.com/balancer-labs/balancer-v2-monorepo # Clone the repository with a custom repository name gclone https://github.com/balancer-labs/balancer-v2-monorepo my-custom-name # Clone the repository without ".git" suffix gclone https://github.com/balancer-labs/balancer-v2-monorepo.git my-custom-name # Clone the repository using short form URL gclone balancer-labs/balancer-v2-monorepo COMMENT # gclone https://github.com/balancer-labs/balancer-v2-monorepo # gclone https://github.com/balancer-labs/balancer-v2-monorepo.git # gclone https://github.com/balancer-labs/balancer-v2-monorepo.git dest gclone() { # Make sure that a URL was passed as an argument if [ -z "$1" ]; then echo "Error: No URL specified" return 1 fi # Prepend "https://github.com" to the URL if it is in the form "user/repo" url="$1" if echo "$url" | grep -Eq '^[^/]+/[^/]+$'; then url="https://github.com/$url" fi # Append ".git" to the URL if it doesn't have that suffix if ! echo "$url" | grep -Eq '\.git$'; then url="$url.git" fi # Prepend "https://github.com" if the URL doesn't have that prefix # If a repository name was not specified as the second argument, extract it from the URL if [ -z "$2" ]; then repo_name=$(echo "$1" | sed -E 's/.*\/([^/]+\/[^/]+).*/\1/') else repo_name=$2 fi # remove .git from repo_name repo_name=$(echo "$repo_name" | sed -E 's/(.*)\.git/\1/') # Clone the repository git clone "$url" "$repo_name" }