@@ -6,6 +6,7 @@ package git
6
6
7
7
import (
8
8
"bytes"
9
+ "context"
9
10
"encoding/base64"
10
11
"errors"
11
12
"io"
@@ -22,11 +23,11 @@ func (b *Blob) Name() string {
22
23
}
23
24
24
25
// GetBlobContent Gets the limited content of the blob as raw text
25
- func (b * Blob ) GetBlobContent (limit int64 ) (string , error ) {
26
+ func (b * Blob ) GetBlobContent (ctx context. Context , limit int64 ) (string , error ) {
26
27
if limit <= 0 {
27
28
return "" , nil
28
29
}
29
- dataRc , err := b .DataAsync ()
30
+ dataRc , err := b .DataAsync (ctx )
30
31
if err != nil {
31
32
return "" , err
32
33
}
@@ -37,8 +38,8 @@ func (b *Blob) GetBlobContent(limit int64) (string, error) {
37
38
38
39
// GetBlobLineCount gets line count of the blob.
39
40
// It will also try to write the content to w if it's not nil, then we could pre-fetch the content without reading it again.
40
- func (b * Blob ) GetBlobLineCount (w io.Writer ) (int , error ) {
41
- reader , err := b .DataAsync ()
41
+ func (b * Blob ) GetBlobLineCount (ctx context. Context , w io.Writer ) (int , error ) {
42
+ reader , err := b .DataAsync (ctx )
42
43
if err != nil {
43
44
return 0 , err
44
45
}
@@ -64,8 +65,8 @@ func (b *Blob) GetBlobLineCount(w io.Writer) (int, error) {
64
65
}
65
66
66
67
// GetBlobContentBase64 Reads the content of the blob with a base64 encode and returns the encoded string
67
- func (b * Blob ) GetBlobContentBase64 () (string , error ) {
68
- dataRc , err := b .DataAsync ()
68
+ func (b * Blob ) GetBlobContentBase64 (ctx context. Context ) (string , error ) {
69
+ dataRc , err := b .DataAsync (ctx )
69
70
if err != nil {
70
71
return "" , err
71
72
}
@@ -93,8 +94,8 @@ func (b *Blob) GetBlobContentBase64() (string, error) {
93
94
}
94
95
95
96
// GuessContentType guesses the content type of the blob.
96
- func (b * Blob ) GuessContentType () (typesniffer.SniffedType , error ) {
97
- r , err := b .DataAsync ()
97
+ func (b * Blob ) GuessContentType (ctx context. Context ) (typesniffer.SniffedType , error ) {
98
+ r , err := b .DataAsync (ctx )
98
99
if err != nil {
99
100
return typesniffer.SniffedType {}, err
100
101
}
0 commit comments