mirror of https://github.com/gogs/gogs.git
vendor: update github.com/gogs/go-gogs-client
parent
e1b3a25008
commit
e755aafe29
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func Version() string {
|
func Version() string {
|
||||||
return "0.12.12"
|
return "0.12.13"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client represents a Gogs API client.
|
// Client represents a Gogs API client.
|
||||||
|
@ -24,7 +24,7 @@ type Client struct {
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient initializes and returns a API client.
|
// NewClient initializes and returns an API client.
|
||||||
func NewClient(url, token string) *Client {
|
func NewClient(url, token string) *Client {
|
||||||
return &Client{
|
return &Client{
|
||||||
url: strings.TrimSuffix(url, "/"),
|
url: strings.TrimSuffix(url, "/"),
|
||||||
|
|
|
@ -50,6 +50,15 @@ type EditOrgOption struct {
|
||||||
Location string `json:"location"`
|
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 {
|
func (c *Client) EditOrg(orgname string, opt EditOrgOption) error {
|
||||||
body, err := json.Marshal(&opt)
|
body, err := json.Marshal(&opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -127,3 +127,21 @@ func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) {
|
||||||
repo := new(Repository)
|
repo := new(Repository)
|
||||||
return repo, c.getParsedResponse("POST", "/repos/migrate", jsonHeader, bytes.NewReader(body), repo)
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollabo
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (c *Client) IsUserFollowing(user, target string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Follow(target string) error {
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,6 +218,12 @@
|
||||||
"revision": "dfc2c1e6d37744c84bf72e4649c87dec93eefffb",
|
"revision": "dfc2c1e6d37744c84bf72e4649c87dec93eefffb",
|
||||||
"revisionTime": "2018-10-23T10:58:32Z"
|
"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=",
|
"checksumSHA1": "GaJLoEuMGnP5ofXvuweAI4wx06U=",
|
||||||
"path": "github.com/golang/protobuf/proto",
|
"path": "github.com/golang/protobuf/proto",
|
||||||
|
|
Loading…
Reference in New Issue