|
@@ -13,3 +13,11 @@ import (
|
|
func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error) {
|
|
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)
|
|
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)
|
|
|
|
+}
|