How to get git patch-id? · gitpython-developers/GitPython · Discussion #1974
Repository navigation
How to get git patch-id? #1974
Answered by jayjoshi64 jayjoshi64 asked this question in Q&A How to get git patch-id? #1974 jayjoshi64 Oct 17, 2024 · 2 comments Answered by jayjoshi64 Return to top Discussion optionsjayjoshi64 Oct 17, 2024
|
This is command-line syntax to get patch-id for a commit
Reference: https://git-scm.com/docs/git-patch-id Q: How can I get the same output using GitPython? |
I got it to work with this:
def get_patch_id(commit: str) -> str:
"""
Get patch-id of a commit.
a patch id is a unique ID for a patch (git show)
ref: https://git-scm.com/docs/git-patch-id
"""
with Repo(repo_path) as repo:
with tempfile.TemporaryFile() as temp_file:
# output_stream = BytesIO()
repo.git.show(commit, output_stream=temp_file)
temp_file.seek(0)
return repo.git.patch_id(istream=temp_file).split()[0]
View full answer
Replies: 2 comments
Comment options
Byron
Oct 18, 2024
Maintainer
|
You would have to use |
jayjoshi64
Oct 18, 2024
Author
|
I got it to work with this:
|