From 3744c70711bce0ab92cc47d7fa9a58f7882cc1e5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Nov 2017 16:23:34 -0500 Subject: add CatBlobWriter --- io.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/io.go b/io.go index f977b73..d8a68bb 100644 --- a/io.go +++ b/io.go @@ -132,3 +132,21 @@ retry: line = _line[:n+len(line)] return } + +type CatBlobWriter struct { + w io.Writer +} + +func (cbw *CatBlobWriter) WriteLine(a ...interface{}) error { + _, err := fmt.Fprintln(cbw.w, a...) + return err +} + +func (cbw *CatBlobWriter) WriteBlob(sha1 string, data []byte) error { + err := cbw.WriteLine(sha1, "blob", len(data)) + if err != nil { + return err + } + _, err = cbw.w.Write(data) + return err +} -- cgit v1.2.3-54-g00ecf