コード例 #1
0
ファイル: signature.go プロジェクト: jgrocho/go-git2
func NewSignature(name, email string, when time.Time) (*Signature, error) {
	sig := new(Signature)
	cname := C.CString(name)
	defer C.free(unsafe.Pointer(cname))
	cemail := C.CString(email)
	defer C.free(unsafe.Pointer(cemail))
	ctime := C.git_time_t(when.Unix())
	_, offset := when.Zone()
	coffset := C.int(offset / 60)
	ecode := C.git_signature_new(&sig.git_signature, cname, cemail, ctime, coffset)
	if ecode != git_SUCCESS {
		return nil, gitError()
	}
	return sig, nil
}
コード例 #2
0
ファイル: commit.go プロジェクト: bradhe/git2go
func (sig *Signature) toC() *C.git_signature {
	var out *C.git_signature

	name := C.CString(sig.Name)
	defer C.free(unsafe.Pointer(name))

	email := C.CString(sig.Email)
	defer C.free(unsafe.Pointer(email))

	ret := C.git_signature_new(&out, name, email, C.git_time_t(sig.When.Unix()), C.int(sig.Offset()))
	if ret < 0 {
		return nil
	}

	return out
}
コード例 #3
0
ファイル: signature.go プロジェクト: wid/git2go
func (sig *Signature) toC() (*C.git_signature, error) {
	if sig == nil {
		return nil, nil
	}

	var out *C.git_signature

	runtime.LockOSThread()
	defer runtime.UnlockOSThread()

	name := C.CString(sig.Name)
	defer C.free(unsafe.Pointer(name))

	email := C.CString(sig.Email)
	defer C.free(unsafe.Pointer(email))

	ret := C.git_signature_new(&out, name, email, C.git_time_t(sig.When.Unix()), C.int(sig.Offset()))
	if ret < 0 {
		return nil, MakeGitError(ret)
	}

	return out, nil
}