Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntoineToubhans/380612ce9b26dc3f2668dd85a7835d06 to your computer and use it in GitHub Desktop.
Save AntoineToubhans/380612ce9b26dc3f2668dd85a7835d06 to your computer and use it in GitHub Desktop.
FIRST_COMMIT = list(REPO.iter_commits())[-1]
@contextmanager
def git_open(path: str, rev: str):
commit = REPO.commit(rev)
# Hack to get the full blob data stream: compute diff with initial commit
diff = commit.diff(FIRST_COMMIT, str(path))[0]
yield diff.a_blob.data_stream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment