I'm trying to find the content of the commits that have been checked in between two specific commits.
In git I'd do git rev-list --ancestry-path <older_commit_sha>..<newer_commit_sha>
.
In git-python, since it doesn't look there's a direct way of doing it, I resorted to calling the exact command, through repo.git.execute()
.
The output is a string of commit IDs (hex SHA).
Now, is there a way in git-python to create a valid Commit
object starting from the hex SHA as given by execute()
?
After much poking, and given this question is not getting much traction, I resorted to using .execute()
.
Specifically:
commits = repo.git.execute(['git', 'rev-list', '--ancestry-path',
'%s..%s' % (oldCommit.hexsha, newCommit.hexsha)]).split()
commits
is a list of str
.
Of course, oldCommit
and newCommit
are git.Commit
objects.