def git_log(repo, prev_head):
r = git.Repo(repo)
if r.head.object.hexsha == prev_head:
return []
git_commit_fields = ['id', 'author_name', 'author_email', 'date', 'message']
git_log_format = ['%H', '%an', '%ae', '%ad', '%s']
git_log_format = '%x1f'.join(git_log_format) + '%x1e'
p = Popen('cd %s && git log %s..HEAD --format="%s"' % (repo, prev_head, git_log_format), shell=True, stdout=PIPE)
(log, _) = p.communicate()
log = log.strip('\n\x1e').split("\x1e")
log = [row.strip().split("\x1f") for row in log]
log = [dict(zip(git_commit_fields, row)) for row in log]
return log
评论列表
文章目录