Unverified Commit 8cb66008 authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Merge pull request #627 from brandon-welsch/feature/add_custom_writer_to_archive

Added custom writer to Archive
parents dbe6fb3e 42ac6352
......@@ -19,6 +19,7 @@ package gitlab
import (
"bytes"
"fmt"
"io"
)
// RepositoriesService handles communication with the repositories related
......@@ -170,6 +171,31 @@ func (s *RepositoriesService) Archive(pid interface{}, opt *ArchiveOptions, opti
return b.Bytes(), resp, err
}
// StreamArchive streams an archive of the repository to the provided
// io.Writer.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/repositories.html#get-file-archive
func (s *RepositoriesService) StreamArchive(pid interface{}, w io.Writer, opt *ArchiveOptions, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, err
}
u := fmt.Sprintf("projects/%s/repository/archive", pathEscape(project))
// Set an optional format for the archive.
if opt != nil && opt.Format != nil {
u = fmt.Sprintf("%s.%s", u, *opt.Format)
}
req, err := s.client.NewRequest("GET", u, opt, options)
if err != nil {
return nil, err
}
return s.client.Do(req, w)
}
// Compare represents the result of a comparison of branches, tags or commits.
//
// GitLab API docs:
......
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