-
-
Notifications
You must be signed in to change notification settings - Fork 399
commit: Add support for getting GPG signature data #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
a37b3ca
to
6e2bca5
Compare
Hi @jdavid! I believe this is ready for your review! Thanks! 😄 |
d8d6c3a
to
f0a1cf7
Compare
src/commit.c
Outdated
|
||
if (err == GIT_ENOTFOUND){ | ||
Py_INCREF(Py_None); Py_INCREF(Py_None); | ||
return Py_BuildValue("OO", Py_None, Py_None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't inc refcount of None
, because the O already does that.
See https://docs.python.org/3/c-api/arg.html#c.Py_BuildValue for the difference between O and N
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I haven't developed too many C extensions for Python. Thanks for explaining O
vs N
!
Fixed!
src/commit.c
Outdated
git_buf_free(&gpg_signature); | ||
git_buf_free(&signed_data); | ||
|
||
return Py_BuildValue("OO", py_gpg_signature, py_signed_data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here use NN instead of OO, because PyBytes_FromString
returns a new reference, otherwise there will be a leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, didn't realize that OO
did that (same as O
vs N
above.
Fixed!
This change adds a new Commit.gpg_signature property which returns a tuple containing the GPG signature for a given commit and the bytes that the signature was computed over. This is accomplished by calling libgit2's git_commit_extract_signature() function.
f0a1cf7
to
64f5259
Compare
@jdavid Thanks for all the feedback. I think I've taken care of all of it if you want to take another look. |
This change adds a new
Commit.gpg_signature
property which returns atuple containing the GPG signature for a given commit and the bytes that
the signature was computed over. This is accomplished by calling
libgit2's
git_commit_extract_signature()
function.