How can I git clone a repository with python, and get the progress of the clone process?
·
Answer a question
I'd like to be able to git clone a large repository using python, using some library, but importantly I'd like to be able to see the progress of the clone as it's happening. I tried pygit2 and GitPython, but they don't seem to show their progress. Is there another way?
Answers
You can use RemoteProgress from GitPython. Here is a crude example:
import git
class Progress(git.remote.RemoteProgress):
def update(self, op_code, cur_count, max_count=None, message=''):
print 'update(%s, %s, %s, %s)'%(op_code, cur_count, max_count, message)
repo = git.Repo.clone_from(
'https://github.com/gitpython-developers/GitPython',
'./git-python',
progress=Progress())
Or use this update() function for a slightly more refined message format:
def update(self, op_code, cur_count, max_count=None, message=''):
print self._cur_line
更多推荐

所有评论(0)