Create adds a note for an object
( ref string, author, committer *Signature, id *Oid, note string, force bool)
| 19 | |
| 20 | // Create adds a note for an object |
| 21 | func (c *NoteCollection) Create( |
| 22 | ref string, author, committer *Signature, id *Oid, |
| 23 | note string, force bool) (*Oid, error) { |
| 24 | |
| 25 | oid := new(Oid) |
| 26 | |
| 27 | var cref *C.char |
| 28 | if ref == "" { |
| 29 | cref = nil |
| 30 | } else { |
| 31 | cref = C.CString(ref) |
| 32 | defer C.free(unsafe.Pointer(cref)) |
| 33 | } |
| 34 | |
| 35 | authorSig, err := author.toC() |
| 36 | if err != nil { |
| 37 | return nil, err |
| 38 | } |
| 39 | defer C.git_signature_free(authorSig) |
| 40 | |
| 41 | committerSig, err := committer.toC() |
| 42 | if err != nil { |
| 43 | return nil, err |
| 44 | } |
| 45 | defer C.git_signature_free(committerSig) |
| 46 | |
| 47 | cnote := C.CString(note) |
| 48 | defer C.free(unsafe.Pointer(cnote)) |
| 49 | |
| 50 | runtime.LockOSThread() |
| 51 | defer runtime.UnlockOSThread() |
| 52 | |
| 53 | ret := C.git_note_create( |
| 54 | oid.toC(), c.repo.ptr, cref, authorSig, |
| 55 | committerSig, id.toC(), cnote, cbool(force)) |
| 56 | runtime.KeepAlive(c) |
| 57 | runtime.KeepAlive(id) |
| 58 | if ret < 0 { |
| 59 | return nil, MakeGitError(ret) |
| 60 | } |
| 61 | return oid, nil |
| 62 | } |
| 63 | |
| 64 | // Read reads the note for an object |
| 65 | func (c *NoteCollection) Read(ref string, id *Oid) (*Note, error) { |
nothing calls this directly
no test coverage detected