Skip to content

Commit 29c0b73

Browse files
authored
Merge pull request #389 from KatolaZ/master
Added Commit.ExtractSignature to wrap git_commit_extract_signature
2 parents 7929e49 + f7e1566 commit 29c0b73

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

commit.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@ func (c Commit) RawMessage() string {
2626
return C.GoString(C.git_commit_message_raw(c.cast_ptr))
2727
}
2828

29+
func (c Commit) ExtractSignature() (string, string, error) {
30+
31+
var c_signed C.git_buf
32+
defer C.git_buf_free(&c_signed)
33+
34+
var c_signature C.git_buf
35+
defer C.git_buf_free(&c_signature)
36+
37+
oid := c.Id()
38+
39+
repo := C.git_commit_owner(c.cast_ptr)
40+
ret := C.git_commit_extract_signature(&c_signature, &c_signed, repo, oid.toC(), nil)
41+
42+
if ret < 0 {
43+
return "", "", MakeGitError(ret)
44+
} else {
45+
return C.GoString(c_signature.ptr), C.GoString(c_signed.ptr), nil
46+
}
47+
48+
}
49+
2950
func (c Commit) Summary() string {
3051
return C.GoString(C.git_commit_summary(c.cast_ptr))
3152
}

0 commit comments

Comments
 (0)