Dont clone already existing repository

This commit is contained in:
Thomas Forgione 2018-10-08 11:18:15 +02:00
parent d6ef67f6c5
commit 90295c4bef
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 8 additions and 2 deletions

View File

@ -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