I've been trying to implement this git syntax git diff HEAD 'HEAD@{7 day ago}' to this diffs = REPO.git.diff('HEAD') GitPython code for some time now without a success.
Couldn't find a helpful document.
How can I look for the diffs of last 7 days with GitPython
Note: Python version: 3.4
I think GitPython doesn't support this command so I've used an other approach.
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')
With this way I was able to achieve what I'm looking for.
Credits to: https://stackoverflow.com/a/15315706/5415084
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With