func (repo *Repository) CreateLightweightTag(name string, target Object, force bool) (*Oid, error) { oid := new(Oid) cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) cforce := C.int(c_FALSE) if force { cforce = C.int(c_TRUE) } ecode := C.git_tag_create_lightweight(oid.git_oid, repo.git_repository, cname, target.git_object, cforce) if ecode != git_SUCCESS { return nil, gitError() } return oid, nil }
// CreateLightweight creates a new lightweight tag pointing to a commit // and returns the id of the target object. // // The name of the tag is validated for consistency (see git_tag_create() for the rules // https://libgit2.github.com/libgit2/#HEAD/group/tag/git_tag_create) and should // not conflict with an already existing tag name. // // If force is true and a reference already exists with the given name, it'll be replaced. // // The created tag is a simple reference and can be queried using // repo.References.Lookup("refs/tags/<name>"). The name of the tag (eg "v1.0.0") // is queried with ref.Shorthand(). func (c *TagsCollection) CreateLightweight(name string, commit *Commit, force bool) (*Oid, error) { oid := new(Oid) cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) ctarget := commit.ptr runtime.LockOSThread() defer runtime.UnlockOSThread() err := C.git_tag_create_lightweight(oid.toC(), c.repo.ptr, cname, ctarget, cbool(force)) if err < 0 { return nil, MakeGitError(err) } return oid, nil }