mirror of
https://github.com/tj/git-extras.git
synced 2026-09-14 17:36:25 -04:00
Merge pull request #552 from npcode/fork-origin
fork: Fork 'origin' remote repo if repo is not given
This commit is contained in:
commit
859bf38c67
10
bin/git-fork
10
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##*:}
|
||||
|
|
|
|||
Loading…
Reference in a new issue