From 76663c26db0a9c07f109d636a6f39af4cace0eaa Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 26 Jul 2016 00:00:19 +0900 Subject: [PATCH] fork: Fork 'origin' remote repo if repo is not given --- bin/git-fork | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/git-fork b/bin/git-fork index b3e4098..a1d93ca 100755 --- a/bin/git-fork +++ b/bin/git-fork @@ -5,8 +5,12 @@ abort() { exit 1 } +url="$1" + +test -z "$url" && url=`git remote get-url origin 2> /dev/null` + # validate repo url -test -z "$1" && abort "github repo needs to be specified as an argument" +test -z "$url" && abort "github repo needs to be specified as an argument" # validate user echo "Enter your github username" @@ -14,8 +18,8 @@ read user [ "$user" = 'n' ] && abort "git username required" # extract owner + project from repo url -project=${1##*/} -owner=${1%/$project} +project=${url##*/} +owner=${url%/$project} [[ $project == *.git ]] && project=${project%.git} if [[ $owner == git@* ]]; then owner=${owner##*:}