diff --git a/zsh/gclone.zsh b/zsh/gclone.zsh index d77b7b5..ac04c49 100644 --- a/zsh/gclone.zsh +++ b/zsh/gclone.zsh @@ -18,14 +18,20 @@ if [ -d "$GCLONE_PATH" ]; then repo=${repo%.*} fi + # Final path to the repo + repo_path=$GCLONE_PATH/$server/$user + + if [ -d $repo_path ]; then + echo "Repository already exists" + return 1 + fi + tempdir=`mktemp -d` git clone $1 $tempdir/$repo # If the clone worked, move the repo in the good place if [ $? -eq 0 ]; then - # Final path to the repo - repo_path=$GCLONE_PATH/$server/$user mkdir -p $repo_path mv $tempdir/$repo $repo_path