diff options
| author | Carlos Martín Nieto <[email protected]> | 2015-03-15 01:09:11 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2015-03-15 01:09:11 +0100 |
| commit | 137c4fc3c838a803dddeb2855e726fc30713fdea (patch) | |
| tree | cc2bbc371b93ed92d4b2f3a1abc2a62d6d578277 /commit.go | |
| parent | 063bed33a90e7d5b1ece1b6bd1aba04a69a78a28 (diff) | |
| parent | 76d600f7b3633f78e5f1433c16eba4eddfdad3e0 (diff) | |
Merge branch 'master' into v22
Diffstat (limited to 'commit.go')
| -rw-r--r-- | commit.go | 52 |
1 files changed, 4 insertions, 48 deletions
@@ -9,8 +9,6 @@ import "C" import ( "runtime" - "time" - "unsafe" ) // Commit @@ -23,6 +21,10 @@ func (c Commit) Message() string { return C.GoString(C.git_commit_message(c.cast_ptr)) } +func (c Commit) Summary() string { + return C.GoString(C.git_commit_summary(c.cast_ptr)) +} + func (c Commit) Tree() (*Tree, error) { var ptr *C.git_tree @@ -68,49 +70,3 @@ func (c *Commit) ParentId(n uint) *Oid { func (c *Commit) ParentCount() uint { return uint(C.git_commit_parentcount(c.cast_ptr)) } - -// Signature - -type Signature struct { - Name string - Email string - When time.Time -} - -func newSignatureFromC(sig *C.git_signature) *Signature { - // git stores minutes, go wants seconds - loc := time.FixedZone("", int(sig.when.offset)*60) - return &Signature{ - C.GoString(sig.name), - C.GoString(sig.email), - time.Unix(int64(sig.when.time), 0).In(loc), - } -} - -// the offset in mintes, which is what git wants -func (v *Signature) Offset() int { - _, offset := v.When.Zone() - return offset / 60 -} - -func (sig *Signature) toC() *C.git_signature { - - if sig == nil { - return nil - } - - 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 -} |
