github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/git/blob_gogit.go (about)

     1  // Copyright 2023 The GitBundle Inc. All rights reserved.
     2  // Copyright 2017 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  
     6  // Copyright 2015 The Gogs Authors. All rights reserved.
     7  
     8  //go:build gogit
     9  
    10  package git
    11  
    12  import (
    13  	"io"
    14  
    15  	"github.com/go-git/go-git/v5/plumbing"
    16  )
    17  
    18  // Blob represents a Git object.
    19  type Blob struct {
    20  	ID SHA1
    21  
    22  	gogitEncodedObj plumbing.EncodedObject
    23  	name            string
    24  }
    25  
    26  // DataAsync gets a ReadCloser for the contents of a blob without reading it all.
    27  // Calling the Close function on the result will discard all unread output.
    28  func (b *Blob) DataAsync() (io.ReadCloser, error) {
    29  	return b.gogitEncodedObj.Reader()
    30  }
    31  
    32  // Size returns the uncompressed size of the blob
    33  func (b *Blob) Size() int64 {
    34  	return b.gogitEncodedObj.Size()
    35  }