Exemplo n.º 1
0
func (repo *Repository) CreateNote(author, committer *Signature, ref string, oid *Oid, note string) (*Oid, error) {
	out := new(Oid)
	var cref *C.char
	if ref != "" {
		cref = C.CString(ref)
		defer C.free(unsafe.Pointer(cref))
	}
	var cnote *C.char
	if note != "" {
		cnote = C.CString(note)
		defer C.free(unsafe.Pointer(cnote))
	}
	ecode := C.git_note_create(out.git_oid, repo.git_repository, author.git_signature, committer.git_signature, cref, oid.git_oid, cnote)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return out, nil
}
Exemplo n.º 2
0
Arquivo: note.go Projeto: wid/git2go
// Create adds a note for an object
func (c *NoteCollection) Create(
	ref string, author, committer *Signature, id *Oid,
	note string, force bool) (*Oid, error) {

	oid := new(Oid)

	var cref *C.char
	if ref == "" {
		cref = nil
	} else {
		cref = C.CString(ref)
		defer C.free(unsafe.Pointer(cref))
	}

	authorSig, err := author.toC()
	if err != nil {
		return nil, err
	}
	defer C.git_signature_free(authorSig)

	committerSig, err := committer.toC()
	if err != nil {
		return nil, err
	}
	defer C.git_signature_free(committerSig)

	cnote := C.CString(note)
	defer C.free(unsafe.Pointer(cnote))

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	ret := C.git_note_create(
		oid.toC(), c.repo.ptr, cref, authorSig,
		committerSig, id.toC(), cnote, cbool(force))

	if ret < 0 {
		return nil, MakeGitError(ret)
	}
	return oid, nil
}