summaryrefslogtreecommitdiff
path: root/commit.go
blob: bba02e80090a0eb7d182aef716fcf908a1a12052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package git

/*
#include <git2.h>
#include <git2/errors.h>

extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr);
*/
import "C"

import (
)

// Commit
type Commit struct {
	ptr *C.git_commit
}

func (c *Commit) Id() *Oid {
	return newOidFromC(C.git_commit_id(c.ptr))
}

func (c *Commit) Message() string {
	return C.GoString(C.git_commit_message(c.ptr))
}

func (c *Commit) Tree() (*Tree, error) {
	tree := new(Tree)

	err := C.git_commit_tree(&tree.ptr, c.ptr)
	if err < 0 {
		return nil, LastError()
	}
	return tree, nil
}

func (c *Commit) TreeId() *Oid {
	return newOidFromC(C.git_commit_tree_id(c.ptr))
}

/* TODO */
/*
func (c *Commit) Author() *Signature {
	ptr := C.git_commit_author(c.ptr)
	return &Signature{ptr}
}

func (c *Commit) Committer() *Signature {
	ptr := C.git_commit_committer(c.ptr)
	return &Signature{ptr}
}
*/