1
1
mirror of https://github.com/go-gitea/gitea synced 2024-11-14 14:14:25 +00:00
gitea/vendor/gopkg.in/src-d/go-git.v4/storage/filesystem/reference.go
Lauris BH 08bf443016 Implement git refs API for listing references (branches, tags and other) (#5354)
* Inital routes to git refs api

* Git refs API implementation

* Update swagger

* Fix copyright

* Make swagger happy add basic test

* Fix test

* Fix test again :)
2018-11-27 16:52:20 -05:00

45 lines
1.0 KiB
Go

package filesystem
import (
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
)
type ReferenceStorage struct {
dir *dotgit.DotGit
}
func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error {
return r.dir.SetRef(ref, nil)
}
func (r *ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error {
return r.dir.SetRef(ref, old)
}
func (r *ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) {
return r.dir.Ref(n)
}
func (r *ReferenceStorage) IterReferences() (storer.ReferenceIter, error) {
refs, err := r.dir.Refs()
if err != nil {
return nil, err
}
return storer.NewReferenceSliceIter(refs), nil
}
func (r *ReferenceStorage) RemoveReference(n plumbing.ReferenceName) error {
return r.dir.RemoveRef(n)
}
func (r *ReferenceStorage) CountLooseRefs() (int, error) {
return r.dir.CountLooseRefs()
}
func (r *ReferenceStorage) PackRefs() error {
return r.dir.PackRefs()
}