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 730B

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