Reputation: 34036
I am cloning from local network using the code below:
_g = cmd.Git(clone_path)
path = os.path.normcase(os.path.normpath(path))
path = path.replace('\\', '/')
_g.clone("-o" + host,
"http://" + host + ':8002' + '/' + path + '/' + '.git',
os.path.join(clone_path, repo))
Now I need to wait for the clone operation to copmplete (succesfully) to proceed. How am I to proceed ?
Upvotes: 0
Views: 2715
Reputation: 4316
In git-python, all direct git calls like repo.git.clone()
are synchronous. There is the option to run it asynchronously using the as_process
flag. Thus, calling repo.git.clone(..., as_process=True)
returns a subprocess.Popen
instance which must be handled accordingly. In the most simple case, you would call communicate()
on it to receive its entire output.
Doing so is usually never needed nor recommended, as git-python provides higher level methods to get the common operation done more conveniently.
If you desire to simplify your code, you could use a higher-level operation, such as this one:
import git
r = git.Repo.clone_from(your_url, checkout_path, origin=host)
r
is a Repo
instance, which is your handle to all git-related operations. The documentation for it is on readthedocs.
Upvotes: 1