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.

blob_gogit.go 802B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. //go:build gogit
  6. package git
  7. import (
  8. "io"
  9. "github.com/go-git/go-git/v5/plumbing"
  10. )
  11. // Blob represents a Git object.
  12. type Blob struct {
  13. ID SHA1
  14. gogitEncodedObj plumbing.EncodedObject
  15. name string
  16. }
  17. // DataAsync gets a ReadCloser for the contents of a blob without reading it all.
  18. // Calling the Close function on the result will discard all unread output.
  19. func (b *Blob) DataAsync() (io.ReadCloser, error) {
  20. return b.gogitEncodedObj.Reader()
  21. }
  22. // Size returns the uncompressed size of the blob
  23. func (b *Blob) Size() int64 {
  24. return b.gogitEncodedObj.Size()
  25. }