vendor: update github.com/gogs/go-gogs-client

pull/5544/head
Unknwon 2018-12-02 12:55:16 -05:00
parent e1b3a25008
commit e755aafe29
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
7 changed files with 45 additions and 4 deletions

View File

@ -14,7 +14,7 @@ import (
)
func Version() string {
return "0.12.12"
return "0.12.13"
}
// Client represents a Gogs API client.
@ -24,7 +24,7 @@ type Client struct {
client *http.Client
}
// NewClient initializes and returns a API client.
// NewClient initializes and returns an API client.
func NewClient(url, token string) *Client {
return &Client{
url: strings.TrimSuffix(url, "/"),

View File

@ -50,6 +50,15 @@ type EditOrgOption struct {
Location string `json:"location"`
}
func (c *Client) CreateOrg(opt CreateOrgOption) (*Organization, error) {
body, err := json.Marshal(&opt)
if err != nil {
return nil, err
}
org := new(Organization)
return org, c.getParsedResponse("POST", "/user/orgs", jsonHeader, bytes.NewReader(body), org)
}
func (c *Client) EditOrg(orgname string, opt EditOrgOption) error {
body, err := json.Marshal(&opt)
if err != nil {

View File

@ -127,3 +127,21 @@ func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) {
repo := new(Repository)
return repo, c.getParsedResponse("POST", "/repos/migrate", jsonHeader, bytes.NewReader(body), repo)
}
type EditIssueTrackerOption struct {
EnableIssues *bool `json:"enable_issues"`
EnableExternalTracker *bool `json:"enable_external_tracker"`
ExternalTrackerURL *string `json:"external_tracker_url"`
TrackerURLFormat *string `json:"tracker_url_format"`
TrackerIssueStyle *string `json:"tracker_issue_style"`
}
// EditIssueTracker updates issue tracker options of the repository.
func (c *Client) EditIssueTracker(owner, repo string, opt EditIssueTrackerOption) error {
body, err := json.Marshal(&opt)
if err != nil {
return err
}
_, err = c.getResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issue-tracker", owner, repo), jsonHeader, bytes.NewReader(body))
return err
}

View File

@ -29,7 +29,7 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo
if err != nil {
return err
}
_, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body))
_, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), jsonHeader, bytes.NewReader(body))
return err
}

View File

@ -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)
}

View File

@ -37,7 +37,7 @@ func (c *Client) IsUserFollowing(user, target string) bool {
}
func (c *Client) Follow(target string) error {
_, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil)
_, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), jsonHeader, nil)
return err
}

6
vendor/vendor.json vendored
View File

@ -218,6 +218,12 @@
"revision": "dfc2c1e6d37744c84bf72e4649c87dec93eefffb",
"revisionTime": "2018-10-23T10:58:32Z"
},
{
"checksumSHA1": "zQkw7E0MzSfPem4f9eCGhue21Nw=",
"path": "github.com/gogs/go-gogs-client",
"revision": "0c040274bc4e176c86a466e2ae327324fc143269",
"revisionTime": "2018-12-02T17:53:48Z"
},
{
"checksumSHA1": "GaJLoEuMGnP5ofXvuweAI4wx06U=",
"path": "github.com/golang/protobuf/proto",