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.

repo_blob.go 737B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package git
  5. import (
  6. "gopkg.in/src-d/go-git.v4/plumbing"
  7. )
  8. func (repo *Repository) getBlob(id SHA1) (*Blob, error) {
  9. encodedObj, err := repo.gogitRepo.Storer.EncodedObject(plumbing.AnyObject, plumbing.Hash(id))
  10. if err != nil {
  11. return nil, ErrNotExist{id.String(), ""}
  12. }
  13. return &Blob{
  14. ID: id,
  15. gogitEncodedObj: encodedObj,
  16. }, nil
  17. }
  18. // GetBlob finds the blob object in the repository.
  19. func (repo *Repository) GetBlob(idStr string) (*Blob, error) {
  20. id, err := NewIDFromString(idStr)
  21. if err != nil {
  22. return nil, err
  23. }
  24. return repo.getBlob(id)
  25. }