0

I have written code to clone the repository using Python Flask.

from flask import Flask, render_template
app=Flask(__name__)
from git.repo.base import Repo
@app.route('/')
def index():
#here i have to write the code to check if the "FolderToSave" already exists! If it doesn't then only clone

Repo.clone_from("https://github.com/***", "FoldertToSave")
return render_template("index.html")
if __name__=='__main__':
   app.run(debug=True)

Is there any method in git to check clone has already present in the local repository??

haronaut
  • 409
  • 3
  • 16
user3359964
  • 347
  • 3
  • 7
  • 16
  • 2
    Is there really any part of this question that has to do with Flask? It sounds like you're asking here about the `git` library. Please try to narrow your question to the exact problem you're having. You'll find it easier for yourself to find an answer to your question if your isolate it from the parts that aren't relevant. – Iguananaut Dec 22 '19 at 11:53
  • 1
    They're not even asking about the `git` library. THey appear to be asking "how do I check if a directory exists?", which would be https://stackoverflow.com/questions/8933237/how-to-find-if-directory-exists-in-python. I'm going to mark this as a duplicate, but feel free to comment if you think I have misread the question. – larsks Dec 22 '19 at 13:50
  • Yes! The above link answer my question. Thank you! – user3359964 Dec 22 '19 at 16:16
  • Hypothetically the library could have a function built-in to check if a given path is a valid git repository (and not just an existing directory), but yes, I agree. – Iguananaut Dec 22 '19 at 17:00

0 Answers0