1

I am working with Django Rest Framework, build some functionality interacts with git repository. I am using gitpython. Now, I used clone_from to clone remote repository.

repo = Repo.clone_from("REMOTE_REPOSITORY", "LOCAL_PATH")

But sometimes it fails with some network connection problems. How can I know repo is cloned correctly or not?

1 Answer 1

3

You can wrap your command in a try, except block

try: repo = Repo.clone_from("REMOTE_REPOSITORY", "LOCAL_PATH") except git.exc.InvalidGitRepositoryError: ....

Catching a sample exception above. A full list of exceptions is available at http://gitpython.readthedocs.io/en/stable/reference.html#module-git.exc

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks - I will try with this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.