GitPython git 最近这么多天的差异

GitPython git diff for the last so many days

一段时间以来,我一直在尝试将此 git 语法 git diff HEAD 'HEAD@{7 day ago}' 实现到此 diffs = REPO.git.diff('HEAD') GitPython 代码,但没有成功。

找不到有用的文档。

如何使用 GitPython

查找最近 7 天的 diffs

注:Python版本:3.4

我认为 GitPython 不支持此命令,所以我使用了其他方法。

git_cmd = "git diff HEAD 'HEAD@{7 day ago}'"
kwargs = {}
kwargs['stdout'] = subprocess.PIPE
kwargs['stderr'] = subprocess.PIPE
kwargs['cwd'] = '/path/to/repo/'
proc = subprocess.Popen(shlex.split(git_cmd), **kwargs)
(stdout_str, stderr_str) = proc.communicate()
return_code = proc.wait()

decoded_list = stdout_str.decode('utf-8')

通过这种方式,我能够实现我正在寻找的东西。

感谢: