Merge pull request #552 from npcode/fork-origin

fork: Fork 'origin' remote repo if repo is not given
This commit is contained in:
hemanth.hm 2016-07-25 21:04:01 +05:30 committed by GitHub
commit 859bf38c67

View file

@ -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##*:}