From 90295c4bef8df53c4cb75b81e5445c4a868ad466 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 8 Oct 2018 11:18:15 +0200 Subject: [PATCH] Dont clone already existing repository --- zsh/gclone.zsh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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