Clone git project from cloud source repository using Python

180 Views Asked by At

I would like to clone git project stored on cloud source repository from Python code. I am using git.Repo.clone_from method and it is working. However, only after I authenticate using procedure described here: https://cloud.google.com/source-repositories/docs/authentication in "Authenticate by using manually generated credentials" section.

This procedure creates .gitcookies file and setup git to use it with my repository. When I use git.Repo.clone_from method, the same cookie is used as this method probably internally runs git command, which also uses .gitcookies file. I would like to be independent from local git configuration and pass some login/password or token directly in my application to git.Repo.clone_from method. Is it possible? I even tried to get the cookie from .gitcookies and pass it to git.Repo.clone_from method using env parameter and set there GIT_ASKPASS variable. Unfortunately without success as I do not know what exactly should be set in it.

0

There are 0 best solutions below