import git
import os.path
repopath = '/path/to/repo'
repo = git.Repo(repopath)
repo.git.archive('<tag>', '-o', '<tag>.zip')
if os.path.exists('<tag>.zip'):
pass
Вы можете перевести почти все команды git на repo.git.<cmd>(arg0, arg1, ...)
.Необходимо заменить -
в имени команды на _
.
git log --oneline -> output = repo.git.log('--oneline')
git commit --allow-empty -m "foo bar" -> output = repo.git.commit('--allow-empty', '-m', 'foo bar')
git ls-tree -r -t HEAD -> output = repo.git.ls_tree('-r', '-t', 'HEAD')