本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.0KB

  1. package filesystem
  2. import (
  3. "gopkg.in/src-d/go-git.v4/plumbing"
  4. "gopkg.in/src-d/go-git.v4/plumbing/storer"
  5. "gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
  6. )
  7. type ReferenceStorage struct {
  8. dir *dotgit.DotGit
  9. }
  10. func (r *ReferenceStorage) SetReference(ref *plumbing.Reference) error {
  11. return r.dir.SetRef(ref, nil)
  12. }
  13. func (r *ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error {
  14. return r.dir.SetRef(ref, old)
  15. }
  16. func (r *ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) {
  17. return r.dir.Ref(n)
  18. }
  19. func (r *ReferenceStorage) IterReferences() (storer.ReferenceIter, error) {
  20. refs, err := r.dir.Refs()
  21. if err != nil {
  22. return nil, err
  23. }
  24. return storer.NewReferenceSliceIter(refs), nil
  25. }
  26. func (r *ReferenceStorage) RemoveReference(n plumbing.ReferenceName) error {
  27. return r.dir.RemoveRef(n)
  28. }
  29. func (r *ReferenceStorage) CountLooseRefs() (int, error) {
  30. return r.dir.CountLooseRefs()
  31. }
  32. func (r *ReferenceStorage) PackRefs() error {
  33. return r.dir.PackRefs()
  34. }
上海开阖软件有限公司 沪ICP备12045867号-1