diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-23 16:32:41 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-23 16:32:41 +0200 |
commit | 6b96b76d66a929a2b428505809fda23a19005c63 (patch) | |
tree | ef653cddb1c45ff23581cd562a5990626d4129af /pkg/git | |
parent | e1664fcbc4685906d3dabc66bf947a17bce7efc0 (diff) | |
download | cerrado-6b96b76d66a929a2b428505809fda23a19005c63.tar.gz cerrado-6b96b76d66a929a2b428505809fda23a19005c63.tar.bz2 cerrado-6b96b76d66a929a2b428505809fda23a19005c63.zip |
fix: Fix bin file not being writen to tar
FileContent was not working for bin file (nor was meant to).
Moving to blob reader solves the issue.
Diffstat (limited to 'pkg/git')
-rw-r--r-- | pkg/git/git.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/git/git.go b/pkg/git/git.go index 591fafb..66338a1 100644 --- a/pkg/git/git.go +++ b/pkg/git/git.go @@ -255,15 +255,22 @@ func (g *GitRepository) WriteTar(w io.Writer, prefix string) error { } if !info.IsDir() { - c, err := g.FileContent(name) + file, err := tree.File(name) if err != nil { return err } - _, err = tw.Write([]byte(c)) + reader, err := file.Blob.Reader() if err != nil { return err } + + _, err = io.Copy(tw, reader) + if err != nil { + reader.Close() + return err + } + reader.Close() } } |