diff options
| author | lhchavez <[email protected]> | 2021-09-03 06:40:31 -0700 |
|---|---|---|
| committer | lhchavez <[email protected]> | 2021-09-05 18:52:01 -0700 |
| commit | 018647fd481a7eb4af97d5f61afc0fddfe76fc24 (patch) | |
| tree | 06f4af28f0298ffe4bd93d2061f7eb8c52518bc2 /commit.go | |
| parent | b78bde3d74b1617d5b635723552aaec0583eb054 (diff) | |
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.
Diffstat (limited to 'commit.go')
| -rw-r--r-- | commit.go | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -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()) |
