From 018647fd481a7eb4af97d5f61afc0fddfe76fc24 Mon Sep 17 00:00:00 2001 From: lhchavez Date: Fri, 3 Sep 2021 06:40:31 -0700 Subject: libgit2 v1.2.0 #major This commit introduces libgit2 v1.2.0 to git2go, which brings a large number of [bugfixes and features](https://github.com/libgit2/libgit2/releases/tag/v1.2.0). This also marks the start of the v32 release. --- commit.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'commit.go') diff --git a/commit.go b/commit.go index 0869ef2..9a09fe7 100644 --- a/commit.go +++ b/commit.go @@ -37,10 +37,14 @@ func (c *Commit) Message() string { return ret } -func (c *Commit) MessageEncoding() string { - ret := C.GoString(C.git_commit_message_encoding(c.cast_ptr)) +func (c *Commit) MessageEncoding() MessageEncoding { + ptr := C.git_commit_message_encoding(c.cast_ptr) + if ptr == nil { + return MessageEncodingUTF8 + } + ret := C.GoString(ptr) runtime.KeepAlive(c) - return ret + return MessageEncoding(ret) } func (c *Commit) RawMessage() string { @@ -64,6 +68,19 @@ func (c *Commit) ContentToSign() string { // CommitSigningCallback defines a function type that takes some data to sign and returns (signature, signature_field, error) type CommitSigningCallback func(string) (signature, signatureField string, err error) +// CommitCreateCallback defines a function type that is called when another +// function is going to create commits (for example, Rebase) to allow callers +// to override the commit creation behavior. For example, users may wish to +// sign commits by providing this information to Repository.CreateCommitBuffer, +// signing that buffer, then calling Repository.CreateCommitWithSignature. +type CommitCreateCallback func( + author, committer *Signature, + messageEncoding MessageEncoding, + message string, + tree *Tree, + parents ...*Commit, +) (oid *Oid, err error) + // WithSignatureUsing creates a new signed commit from this one using the given signing callback func (c *Commit) WithSignatureUsing(f CommitSigningCallback) (*Oid, error) { signature, signatureField, err := f(c.ContentToSign()) -- cgit v1.2.3