Added custom writer to Archive

parent dbe6fb3e
...@@ -19,6 +19,7 @@ package gitlab ...@@ -19,6 +19,7 @@ package gitlab
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io"
) )
// RepositoriesService handles communication with the repositories related // RepositoriesService handles communication with the repositories related
...@@ -138,6 +139,7 @@ func (s *RepositoriesService) RawBlobContent(pid interface{}, sha string, option ...@@ -138,6 +139,7 @@ func (s *RepositoriesService) RawBlobContent(pid interface{}, sha string, option
type ArchiveOptions struct { type ArchiveOptions struct {
Format *string `url:"-" json:"-"` Format *string `url:"-" json:"-"`
SHA *string `url:"sha,omitempty" json:"sha,omitempty"` SHA *string `url:"sha,omitempty" json:"sha,omitempty"`
Writer *io.Writer `url:"-" json:"-"`
} }
// Archive gets an archive of the repository. // Archive gets an archive of the repository.
...@@ -162,7 +164,13 @@ func (s *RepositoriesService) Archive(pid interface{}, opt *ArchiveOptions, opti ...@@ -162,7 +164,13 @@ func (s *RepositoriesService) Archive(pid interface{}, opt *ArchiveOptions, opti
} }
var b bytes.Buffer var b bytes.Buffer
resp, err := s.client.Do(req, &b) var resp *Response
if opt != nil && opt.Writer != nil {
resp, err = s.client.Do(req, opt.Writer)
} else {
resp, err = s.client.Do(req, &b)
}
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment