diff options
| author | lhchavez <[email protected]> | 2021-09-04 13:49:01 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-09-04 13:49:01 -0700 |
| commit | 15434610fec67e704d3ad443b03054d1611f98fe (patch) | |
| tree | 76d1416b98bfdd907f8cc5c13628fa5d0c9f145d /repository.go | |
| parent | be5a99a807beb2fd79dc0ca71b5a92611b1eda52 (diff) | |
Add `CreateCommitWithSignature` (#782)
This change adds the wrapper for `git_commit_create_with_signature`.
Diffstat (limited to 'repository.go')
| -rw-r--r-- | repository.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/repository.go b/repository.go index dc40aaf..9735c63 100644 --- a/repository.go +++ b/repository.go @@ -485,6 +485,39 @@ func (v *Repository) CreateCommit( return oid, nil } +// CreateCommitWithSignature creates a commit object from the given contents and +// signature. +func (v *Repository) CreateCommitWithSignature( + commitContent, signature, signatureField string, +) (*Oid, error) { + cCommitContent := C.CString(commitContent) + defer C.free(unsafe.Pointer(cCommitContent)) + var cSignature *C.char + if signature != "" { + cSignature = C.CString(string(signature)) + defer C.free(unsafe.Pointer(cSignature)) + } + var cSignatureField *C.char + if signatureField != "" { + cSignatureField = C.CString(string(signatureField)) + defer C.free(unsafe.Pointer(cSignatureField)) + } + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + + oid := new(Oid) + ret := C.git_commit_create_with_signature(oid.toC(), v.ptr, cCommitContent, cSignature, cSignatureField) + + runtime.KeepAlive(v) + runtime.KeepAlive(oid) + if ret < 0 { + return nil, MakeGitError(ret) + } + + return oid, nil +} + // CreateCommitBuffer creates a commit and write it into a buffer. func (v *Repository) CreateCommitBuffer( author, committer *Signature, |
