Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c84e492

Browse files
eriknstevensonunknwon
authored andcommitted
Implement GetArchive (#93)
* Implement GetArchive * Fix capitalization in error message.
1 parent 5898069 commit c84e492

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎repo_file.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ import (
1313
func (c *Client) GetFile(user, repo, ref, tree string) ([]byte, error) {
1414
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/raw/%s/%s", user, repo, ref, tree), nil, nil)
1515
}
16+
17+
// GetArchive downloads the full contents of a repository. Ref can be a branch/tag/commit.
18+
func (c *Client) GetArchive(user, repo, ref, format string) ([]byte, error) {
19+
if format != ".zip" && format != ".tar.gz" {
20+
return nil, fmt.Errorf("invalid format: %s (must be .zip or .tar.gz)", format)
21+
}
22+
return c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/archive/%s%s", user, repo, ref, format), nil, nil)
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /