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

12345678910111213141516171819202122232425262728293031323334
  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. // +build gogit
  7. package git
  8. import (
  9. "io"
  10. "github.com/go-git/go-git/v5/plumbing"
  11. )
  12. // Blob represents a Git object.
  13. type Blob struct {
  14. ID SHA1
  15. gogitEncodedObj plumbing.EncodedObject
  16. name string
  17. }
  18. // DataAsync gets a ReadCloser for the contents of a blob without reading it all.
  19. // Calling the Close function on the result will discard all unread output.
  20. func (b *Blob) DataAsync() (io.ReadCloser, error) {
  21. return b.gogitEncodedObj.Reader()
  22. }
  23. // Size returns the uncompressed size of the blob
  24. func (b *Blob) Size() int64 {
  25. return b.gogitEncodedObj.Size()
  26. }