summaryrefslogtreecommitdiff
path: root/tag.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-07-31 20:23:05 +0200
committerCarlos Martín Nieto <[email protected]>2015-07-31 20:23:05 +0200
commitdef4494b74ec1c8fd12669e3f65bd29d6315c83c (patch)
tree8ef9d2c2c6628d0dbfc8b26f7407c18c7aaf869c /tag.go
parent6c4af98c5b2763b020e39357f31bcc6d6f1960e1 (diff)
Move CreateTag to the tags collection
Diffstat (limited to 'tag.go')
-rw-r--r--tag.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/tag.go b/tag.go
index 5801c99..ca85156 100644
--- a/tag.go
+++ b/tag.go
@@ -53,6 +53,36 @@ type TagsCollection struct {
repo *Repository
}
+func (c *TagsCollection) Create(
+ name string, commit *Commit, tagger *Signature, message string) (*Oid, error) {
+
+ oid := new(Oid)
+
+ cname := C.CString(name)
+ defer C.free(unsafe.Pointer(cname))
+
+ cmessage := C.CString(message)
+ defer C.free(unsafe.Pointer(cmessage))
+
+ taggerSig, err := tagger.toC()
+ if err != nil {
+ return nil, err
+ }
+ defer C.git_signature_free(taggerSig)
+
+ ctarget := commit.gitObject.ptr
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ret := C.git_tag_create(oid.toC(), c.repo.ptr, cname, ctarget, taggerSig, cmessage, 0)
+ if ret < 0 {
+ return nil, MakeGitError(ret)
+ }
+
+ return oid, nil
+}
+
// CreateLightweight creates a new lightweight tag pointing to a commit
// and returns the id of the target object.
//