From dc805ef3dac04e4f223a36a1d158cd82645a55ba Mon Sep 17 00:00:00 2001 From: Erik Stevenson Date: Sat, 21 Jul 2018 14:26:32 -0500 Subject: [PATCH 1/2] Implement GetArchive --- repo_file.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/repo_file.go b/repo_file.go index c50708b..b9dddd0 100644 --- a/repo_file.go +++ b/repo_file.go @@ -13,3 +13,11 @@ import ( func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error) { return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s/%s", user, repo, ref, tree), nil, nil) } + +// GetArchive downloads the full contents of a repository. Ref can be a branch/tag/commit. +func (c *Client) GetArchive(user, repo, ref, format string) ([]byte, error) { + if format != ".zip" && format != ".tar.gz" { + return nil, fmt.Errorf("Invalid format: %s (Must be .zip or .tar.gz)", format) + } + return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", user, repo, ref, format), nil, nil) +} From b6b721826d72c75ab714403225171f5119539f56 Mon Sep 17 00:00:00 2001 From: Erik Stevenson Date: Fri, 17 Aug 2018 06:13:36 -0500 Subject: [PATCH 2/2] Fix capitalization in error message. --- repo_file.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repo_file.go b/repo_file.go index b9dddd0..d766fb6 100644 --- a/repo_file.go +++ b/repo_file.go @@ -17,7 +17,7 @@ func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error) { // GetArchive downloads the full contents of a repository. Ref can be a branch/tag/commit. func (c *Client) GetArchive(user, repo, ref, format string) ([]byte, error) { if format != ".zip" && format != ".tar.gz" { - return nil, fmt.Errorf("Invalid format: %s (Must be .zip or .tar.gz)", format) + return nil, fmt.Errorf("invalid format: %s (must be .zip or .tar.gz)", format) } return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", user, repo, ref, format), nil, nil) }