diff --git a/gitea/repo_transfer.go b/gitea/repo_transfer.go index be06010..534a6e4 100644 --- a/gitea/repo_transfer.go +++ b/gitea/repo_transfer.go @@ -34,3 +34,29 @@ func (c *Client) TransferRepo(owner, reponame string, opt TransferRepoOption) (* resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/transfer", owner, reponame), jsonHeader, bytes.NewReader(body), repo) return repo, resp, err } + +// AcceptRepoTransfer accepts a repo transfer. +func (c *Client) AcceptRepoTransfer(owner, reponame string) (*Repository, *Response, error) { + if err := escapeValidatePathSegments(&owner, &reponame); err != nil { + return nil, nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_16_0); err != nil { + return nil, nil, err + } + repo := new(Repository) + resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/transfer/accept", owner, reponame), jsonHeader, nil, repo) + return repo, resp, err +} + +// RejectRepoTransfer rejects a repo transfer. +func (c *Client) RejectRepoTransfer(owner, reponame string) (*Repository, *Response, error) { + if err := escapeValidatePathSegments(&owner, &reponame); err != nil { + return nil, nil, err + } + if err := c.checkServerVersionGreaterThanOrEqual(version1_16_0); err != nil { + return nil, nil, err + } + repo := new(Repository) + resp, err := c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/transfer/reject", owner, reponame), jsonHeader, nil, repo) + return repo, resp, err +} diff --git a/gitea/version.go b/gitea/version.go index 1f41c77..a7c62f8 100644 --- a/gitea/version.go +++ b/gitea/version.go @@ -12,7 +12,7 @@ import ( // ServerVersion returns the version of the server func (c *Client) ServerVersion() (string, *Response, error) { - var v = struct { + v := struct { Version string `json:"version"` }{} resp, err := c.getParsedResponse("GET", "/version", nil, nil, &v) @@ -65,6 +65,7 @@ var ( version1_13_0, _ = version.NewVersion("1.13.0") version1_14_0, _ = version.NewVersion("1.14.0") version1_15_0, _ = version.NewVersion("1.15.0") + version1_16_0, _ = version.NewVersion("1.16.0") ) // checkServerVersionGreaterThanOrEqual is the canonical way in the SDK to check for versions for API compatibility reasons