Add func (c Commit) Time() time.Time #410
|
@ -9,6 +9,7 @@ import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -18,6 +19,10 @@ type Commit struct {
|
||||||
cast_ptr *C.git_commit
|
cast_ptr *C.git_commit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Commit) Time() time.Time {
|
||||||
|
return time.Unix(int64(C.git_commit_time(c.cast_ptr)), 0)
|
||||||
|
}
|
||||||
|
|
||||||
func (c Commit) Message() string {
|
func (c Commit) Message() string {
|
||||||
return C.GoString(C.git_commit_message(c.cast_ptr))
|
return C.GoString(C.git_commit_message(c.cast_ptr))
|
||||||
}
|
}
|
||||||
|
|
2
graph.go
2
graph.go
|
@ -17,7 +17,7 @@ func (repo *Repository) DescendantOf(commit, ancestor *Oid) (bool, error) {
|
||||||
return false, MakeGitError(ret)
|
return false, MakeGitError(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret > 0), nil
|
return ret > 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) AheadBehind(local, upstream *Oid) (ahead, behind int, err error) {
|
func (repo *Repository) AheadBehind(local, upstream *Oid) (ahead, behind int, err error) {
|
||||||
|
|
2
odb.go
2
odb.go
|
@ -236,7 +236,7 @@ func (object *OdbObject) Data() (data []byte) {
|
||||||
|
|
||||||
len := int(C.git_odb_object_size(object.ptr))
|
len := int(C.git_odb_object_size(object.ptr))
|
||||||
|
|
||||||
sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&blob)))
|
sliceHeader := (*reflect.SliceHeader)(unsafe.Pointer(&blob))
|
||||||
sliceHeader.Cap = len
|
sliceHeader.Cap = len
|
||||||
sliceHeader.Len = len
|
sliceHeader.Len = len
|
||||||
sliceHeader.Data = uintptr(c_blob)
|
sliceHeader.Data = uintptr(c_blob)
|
||||||
|
|
|
@ -11,9 +11,9 @@ type pathPair struct {
|
||||||
|
|
||||||
func TestSearchPath(t *testing.T) {
|
func TestSearchPath(t *testing.T) {
|
||||||
paths := []pathPair{
|
paths := []pathPair{
|
||||||
pathPair{ConfigLevelSystem, "/tmp/system"},
|
{ConfigLevelSystem, "/tmp/system"},
|
||||||
pathPair{ConfigLevelGlobal, "/tmp/global"},
|
{ConfigLevelGlobal, "/tmp/global"},
|
||||||
pathPair{ConfigLevelXDG, "/tmp/xdg"},
|
{ConfigLevelXDG, "/tmp/xdg"},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pair := range paths {
|
for _, pair := range paths {
|
||||||
|
|
Loading…
Reference in New Issue