diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-05-11 18:21:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-11 18:21:34 +0800 |
commit | 34eee25bd42d19287e3e33afd169cc979ab61f37 (patch) | |
tree | 8def3b2f224745e3fbc0adaec2f01d7f752c443d /vendor/code.gitea.io | |
parent | 1658cd04e9918109867f2745ddf760d260681878 (diff) | |
download | gitea-34eee25bd42d19287e3e33afd169cc979ab61f37.tar.gz gitea-34eee25bd42d19287e3e33afd169cc979ab61f37.zip |
Move sdk structs to modules/structs (#6905)
* move sdk structs to moduels/structs
* fix tests
* fix fmt
* fix swagger
* fix vendor
Diffstat (limited to 'vendor/code.gitea.io')
43 files changed, 0 insertions, 3240 deletions
diff --git a/vendor/code.gitea.io/sdk/LICENSE b/vendor/code.gitea.io/sdk/LICENSE deleted file mode 100644 index 10aeba46bc..0000000000 --- a/vendor/code.gitea.io/sdk/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2016 The Gitea Authors -Copyright (c) 2014 The Gogs Authors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/code.gitea.io/sdk/gitea/admin_org.go b/vendor/code.gitea.io/sdk/gitea/admin_org.go deleted file mode 100644 index 4071b6f187..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/admin_org.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// AdminCreateOrg create an organization -func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - org := new(Organization) - return org, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/orgs", user), - jsonHeader, bytes.NewReader(body), org) -} diff --git a/vendor/code.gitea.io/sdk/gitea/admin_repo.go b/vendor/code.gitea.io/sdk/gitea/admin_repo.go deleted file mode 100644 index cf565ffa38..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/admin_repo.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// AdminCreateRepo create a repo -func (c *Client) AdminCreateRepo(user string, opt CreateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/repos", user), - jsonHeader, bytes.NewReader(body), repo) -} diff --git a/vendor/code.gitea.io/sdk/gitea/admin_user.go b/vendor/code.gitea.io/sdk/gitea/admin_user.go deleted file mode 100644 index a4df703b17..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/admin_user.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// CreateUserOption create user options -type CreateUserOption struct { - SourceID int64 `json:"source_id"` - LoginName string `json:"login_name"` - // required: true - Username string `json:"username" binding:"Required;AlphaDashDot;MaxSize(40)"` - FullName string `json:"full_name" binding:"MaxSize(100)"` - // required: true - // swagger:strfmt email - Email string `json:"email" binding:"Required;Email;MaxSize(254)"` - // required: true - Password string `json:"password" binding:"Required;MaxSize(255)"` - MustChangePassword *bool `json:"must_change_password"` - SendNotify bool `json:"send_notify"` -} - -// AdminCreateUser create a user -func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - user := new(User) - return user, c.getParsedResponse("POST", "/admin/users", jsonHeader, bytes.NewReader(body), user) -} - -// EditUserOption edit user options -type EditUserOption struct { - SourceID int64 `json:"source_id"` - LoginName string `json:"login_name"` - FullName string `json:"full_name" binding:"MaxSize(100)"` - // required: true - // swagger:strfmt email - Email string `json:"email" binding:"Required;Email;MaxSize(254)"` - Password string `json:"password" binding:"MaxSize(255)"` - MustChangePassword *bool `json:"must_change_password"` - Website string `json:"website" binding:"MaxSize(50)"` - Location string `json:"location" binding:"MaxSize(50)"` - Active *bool `json:"active"` - Admin *bool `json:"admin"` - AllowGitHook *bool `json:"allow_git_hook"` - AllowImportLocal *bool `json:"allow_import_local"` - MaxRepoCreation *int `json:"max_repo_creation"` - ProhibitLogin *bool `json:"prohibit_login"` - AllowCreateOrganization *bool `json:"allow_create_organization"` -} - -// AdminEditUser modify user informations -func (c *Client) AdminEditUser(user string, opt EditUserOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/admin/users/%s", user), jsonHeader, bytes.NewReader(body)) - return err -} - -// AdminDeleteUser delete one user according name -func (c *Client) AdminDeleteUser(user string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s", user), nil, nil) - return err -} - -// AdminCreateUserPublicKey create one user with options -func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(PublicKey) - return key, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/keys", user), jsonHeader, bytes.NewReader(body), key) -} diff --git a/vendor/code.gitea.io/sdk/gitea/attachment.go b/vendor/code.gitea.io/sdk/gitea/attachment.go deleted file mode 100644 index 8c527de735..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/attachment.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea // import "code.gitea.io/sdk/gitea" -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "mime/multipart" - "net/http" - "time" -) - -// Attachment a generic attachment -// swagger:model -type Attachment struct { - ID int64 `json:"id"` - Name string `json:"name"` - Size int64 `json:"size"` - DownloadCount int64 `json:"download_count"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - UUID string `json:"uuid"` - DownloadURL string `json:"browser_download_url"` -} - -// ListReleaseAttachments list release's attachments -func (c *Client) ListReleaseAttachments(user, repo string, release int64) ([]*Attachment, error) { - attachments := make([]*Attachment, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release), - nil, nil, &attachments) - return attachments, err -} - -// GetReleaseAttachment returns the requested attachment -func (c *Client) GetReleaseAttachment(user, repo string, release int64, id int64) (*Attachment, error) { - a := new(Attachment) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), - nil, nil, &a) - return a, err -} - -// CreateReleaseAttachment creates an attachment for the given release -func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file io.Reader, filename string) (*Attachment, error) { - // Write file to body - body := new(bytes.Buffer) - writer := multipart.NewWriter(body) - part, err := writer.CreateFormFile("attachment", filename) - if err != nil { - return nil, err - } - - if _, err = io.Copy(part, file); err != nil { - return nil, err - } - if err = writer.Close(); err != nil { - return nil, err - } - - // Send request - attachment := new(Attachment) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/releases/%d/assets", user, repo, release), - http.Header{"Content-Type": {writer.FormDataContentType()}}, body, &attachment) - return attachment, err -} - -// EditReleaseAttachment updates the given attachment with the given options -func (c *Client) EditReleaseAttachment(user, repo string, release int64, attachment int64, form EditAttachmentOptions) (*Attachment, error) { - body, err := json.Marshal(&form) - if err != nil { - return nil, err - } - attach := new(Attachment) - return attach, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, attachment), jsonHeader, bytes.NewReader(body), attach) -} - -// DeleteReleaseAttachment deletes the given attachment including the uploaded file -func (c *Client) DeleteReleaseAttachment(user, repo string, release int64, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/releases/%d/assets/%d", user, repo, release, id), nil, nil) - return err -} - -// EditAttachmentOptions options for editing attachments -// swagger:model -type EditAttachmentOptions struct { - Name string `json:"name"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/doc.go b/vendor/code.gitea.io/sdk/gitea/doc.go deleted file mode 100644 index 6bd327db46..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2016 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea // import "code.gitea.io/sdk/gitea" diff --git a/vendor/code.gitea.io/sdk/gitea/fork.go b/vendor/code.gitea.io/sdk/gitea/fork.go deleted file mode 100644 index 57222498ef..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/fork.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// ListForks list a repository's forks -func (c *Client) ListForks(user, repo string) ([]*Repository, error) { - forks := make([]*Repository, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/forks", user, repo), - nil, nil, &forks) - return forks, err -} - -// CreateForkOption options for creating a fork -type CreateForkOption struct { - // organization name, if forking into an organization - Organization *string `json:"organization"` -} - -// CreateFork create a fork of a repository -func (c *Client) CreateFork(user, repo string, form CreateForkOption) (*Repository, error) { - body, err := json.Marshal(form) - if err != nil { - return nil, err - } - fork := new(Repository) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/forks", user, repo), - jsonHeader, bytes.NewReader(body), &fork) - return fork, err -} diff --git a/vendor/code.gitea.io/sdk/gitea/git_blob.go b/vendor/code.gitea.io/sdk/gitea/git_blob.go deleted file mode 100644 index abdd95aaff..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/git_blob.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -// GitBlobResponse represents a git blob -type GitBlobResponse struct { - Content string `json:"content"` - Encoding string `json:"encoding"` - URL string `json:"url"` - SHA string `json:"sha"` - Size int64 `json:"size"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/git_hook.go b/vendor/code.gitea.io/sdk/gitea/git_hook.go deleted file mode 100644 index d47fe1d0ca..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/git_hook.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// GitHook represents a Git repository hook -type GitHook struct { - Name string `json:"name"` - IsActive bool `json:"is_active"` - Content string `json:"content,omitempty"` -} - -// GitHookList represents a list of Git hooks -type GitHookList []*GitHook - -// ListRepoGitHooks list all the Git hooks of one repository -func (c *Client) ListRepoGitHooks(user, repo string) (GitHookList, error) { - hooks := make([]*GitHook, 0, 10) - return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git", user, repo), nil, nil, &hooks) -} - -// GetRepoGitHook get a Git hook of a repository -func (c *Client) GetRepoGitHook(user, repo, id string) (*GitHook, error) { - h := new(GitHook) - return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil, h) -} - -// EditGitHookOption options when modifying one Git hook -type EditGitHookOption struct { - Content string `json:"content"` -} - -// EditRepoGitHook modify one Git hook of a repository -func (c *Client) EditRepoGitHook(user, repo, id string, opt EditGitHookOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), jsonHeader, bytes.NewReader(body)) - return err -} - -// DeleteRepoGitHook delete one Git hook from a repository -func (c *Client) DeleteRepoGitHook(user, repo, id string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/git/%s", user, repo, id), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/gitea.go b/vendor/code.gitea.io/sdk/gitea/gitea.go deleted file mode 100644 index fa35e09555..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/gitea.go +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "strings" -) - -// Version return the library version -func Version() string { - return "0.12.3" -} - -// Client represents a Gogs API client. -type Client struct { - url string - accessToken string - sudo string - client *http.Client -} - -// NewClient initializes and returns a API client. -func NewClient(url, token string) *Client { - return &Client{ - url: strings.TrimSuffix(url, "/"), - accessToken: token, - client: &http.Client{}, - } -} - -// NewClientWithHTTP creates an API client with a custom http client -func NewClientWithHTTP(url string, httpClient *http.Client) { - client := NewClient(url, "") - client.client = httpClient -} - -// SetHTTPClient replaces default http.Client with user given one. -func (c *Client) SetHTTPClient(client *http.Client) { - c.client = client -} - -// SetSudo sets username to impersonate. -func (c *Client) SetSudo(sudo string) { - c.sudo = sudo -} - -func (c *Client) doRequest(method, path string, header http.Header, body io.Reader) (*http.Response, error) { - req, err := http.NewRequest(method, c.url+"/api/v1"+path, body) - if err != nil { - return nil, err - } - if len(c.accessToken) != 0 { - req.Header.Set("Authorization", "token "+c.accessToken) - } - if c.sudo != "" { - req.Header.Set("Sudo", c.sudo) - } - for k, v := range header { - req.Header[k] = v - } - - return c.client.Do(req) -} - -func (c *Client) getResponse(method, path string, header http.Header, body io.Reader) ([]byte, error) { - resp, err := c.doRequest(method, path, header, body) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - data, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - switch resp.StatusCode { - case 403: - return nil, errors.New("403 Forbidden") - case 404: - return nil, errors.New("404 Not Found") - case 409: - return nil, errors.New("409 Conflict") - case 422: - return nil, fmt.Errorf("422 Unprocessable Entity: %s", string(data)) - } - - if resp.StatusCode/100 != 2 { - errMap := make(map[string]interface{}) - if err = json.Unmarshal(data, &errMap); err != nil { - // when the JSON can't be parsed, data was probably empty or a plain string, - // so we try to return a helpful error anyway - return nil, fmt.Errorf("Unknown API Error: %d %s", resp.StatusCode, string(data)) - } - return nil, errors.New(errMap["message"].(string)) - } - - return data, nil -} - -func (c *Client) getParsedResponse(method, path string, header http.Header, body io.Reader, obj interface{}) error { - data, err := c.getResponse(method, path, header, body) - if err != nil { - return err - } - return json.Unmarshal(data, obj) -} - -func (c *Client) getStatusCode(method, path string, header http.Header, body io.Reader) (int, error) { - resp, err := c.doRequest(method, path, header, body) - if err != nil { - return -1, err - } - defer resp.Body.Close() - - return resp.StatusCode, nil -} diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/vendor/code.gitea.io/sdk/gitea/hook.go deleted file mode 100644 index d36e4d4375..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ /dev/null @@ -1,543 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "strings" - "time" -) - -var ( - // ErrInvalidReceiveHook FIXME - ErrInvalidReceiveHook = errors.New("Invalid JSON payload received over webhook") -) - -// Hook a hook is a web hook when one repository changed -type Hook struct { - ID int64 `json:"id"` - Type string `json:"type"` - URL string `json:"-"` - Config map[string]string `json:"config"` - Events []string `json:"events"` - Active bool `json:"active"` - // swagger:strfmt date-time - Updated time.Time `json:"updated_at"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` -} - -// HookList represents a list of API hook. -type HookList []*Hook - -// ListOrgHooks list all the hooks of one organization -func (c *Client) ListOrgHooks(org string) (HookList, error) { - hooks := make([]*Hook, 0, 10) - return hooks, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks", org), nil, nil, &hooks) -} - -// ListRepoHooks list all the hooks of one repository -func (c *Client) ListRepoHooks(user, repo string) (HookList, error) { - hooks := make([]*Hook, 0, 10) - return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks) -} - -// GetOrgHook get a hook of an organization -func (c *Client) GetOrgHook(org string, id int64) (*Hook, error) { - h := new(Hook) - return h, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil, h) -} - -// GetRepoHook get a hook of a repository -func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) { - h := new(Hook) - return h, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil, h) -} - -// CreateHookOption options when create a hook -type CreateHookOption struct { - // required: true - // enum: gitea,gogs,slack,discord - Type string `json:"type" binding:"Required"` - // required: true - Config map[string]string `json:"config" binding:"Required"` - Events []string `json:"events"` - // default: false - Active bool `json:"active"` -} - -// CreateOrgHook create one hook for an organization, with options -func (c *Client) CreateOrgHook(org string, opt CreateHookOption) (*Hook, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - h := new(Hook) - return h, c.getParsedResponse("POST", fmt.Sprintf("/orgs/%s/hooks", org), jsonHeader, bytes.NewReader(body), h) -} - -// CreateRepoHook create one hook for a repository, with options -func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - h := new(Hook) - return h, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), jsonHeader, bytes.NewReader(body), h) -} - -// EditHookOption options when modify one hook -type EditHookOption struct { - Config map[string]string `json:"config"` - Events []string `json:"events"` - Active *bool `json:"active"` -} - -// EditOrgHook modify one hook of an organization, with hook id and options -func (c *Client) EditOrgHook(org string, id int64, opt EditHookOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), jsonHeader, bytes.NewReader(body)) - return err -} - -// EditRepoHook modify one hook of a repository, with hook id and options -func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), jsonHeader, bytes.NewReader(body)) - return err -} - -// DeleteOrgHook delete one hook from an organization, with hook id -func (c *Client) DeleteOrgHook(org string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/org/%s/hooks/%d", org, id), nil, nil) - return err -} - -// DeleteRepoHook delete one hook from a repository, with hook id -func (c *Client) DeleteRepoHook(user, repo string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/hooks/%d", user, repo, id), nil, nil) - return err -} - -// Payloader payload is some part of one hook -type Payloader interface { - SetSecret(string) - JSONPayload() ([]byte, error) -} - -// PayloadUser represents the author or committer of a commit -type PayloadUser struct { - // Full name of the commit author - Name string `json:"name"` - // swagger:strfmt email - Email string `json:"email"` - UserName string `json:"username"` -} - -// FIXME: consider using same format as API when commits API are added. -// applies to PayloadCommit and PayloadCommitVerification - -// PayloadCommit represents a commit -type PayloadCommit struct { - // sha1 hash of the commit - ID string `json:"id"` - Message string `json:"message"` - URL string `json:"url"` - Author *PayloadUser `json:"author"` - Committer *PayloadUser `json:"committer"` - Verification *PayloadCommitVerification `json:"verification"` - // swagger:strfmt date-time - Timestamp time.Time `json:"timestamp"` - Added []string `json:"added"` - Removed []string `json:"removed"` - Modified []string `json:"modified"` -} - -// PayloadCommitVerification represents the GPG verification of a commit -type PayloadCommitVerification struct { - Verified bool `json:"verified"` - Reason string `json:"reason"` - Signature string `json:"signature"` - Payload string `json:"payload"` -} - -var ( - _ Payloader = &CreatePayload{} - _ Payloader = &DeletePayload{} - _ Payloader = &ForkPayload{} - _ Payloader = &PushPayload{} - _ Payloader = &IssuePayload{} - _ Payloader = &IssueCommentPayload{} - _ Payloader = &PullRequestPayload{} - _ Payloader = &RepositoryPayload{} - _ Payloader = &ReleasePayload{} -) - -// _________ __ -// \_ ___ \_______ ____ _____ _/ |_ ____ -// / \ \/\_ __ \_/ __ \\__ \\ __\/ __ \ -// \ \____| | \/\ ___/ / __ \| | \ ___/ -// \______ /|__| \___ >____ /__| \___ > -// \/ \/ \/ \/ - -// CreatePayload FIXME -type CreatePayload struct { - Secret string `json:"secret"` - Sha string `json:"sha"` - Ref string `json:"ref"` - RefType string `json:"ref_type"` - Repo *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the CreatePayload -func (p *CreatePayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload return payload information -func (p *CreatePayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// ParseCreateHook parses create event hook content. -func ParseCreateHook(raw []byte) (*CreatePayload, error) { - hook := new(CreatePayload) - if err := json.Unmarshal(raw, hook); err != nil { - return nil, err - } - - // it is possible the JSON was parsed, however, - // was not from Gogs (maybe was from Bitbucket) - // So we'll check to be sure certain key fields - // were populated - switch { - case hook.Repo == nil: - return nil, ErrInvalidReceiveHook - case len(hook.Ref) == 0: - return nil, ErrInvalidReceiveHook - } - return hook, nil -} - -// ________ .__ __ -// \______ \ ____ | | _____/ |_ ____ -// | | \_/ __ \| | _/ __ \ __\/ __ \ -// | ` \ ___/| |_\ ___/| | \ ___/ -// /_______ /\___ >____/\___ >__| \___ > -// \/ \/ \/ \/ - -// PusherType define the type to push -type PusherType string - -// describe all the PusherTypes -const ( - PusherTypeUser PusherType = "user" -) - -// DeletePayload represents delete payload -type DeletePayload struct { - Secret string `json:"secret"` - Ref string `json:"ref"` - RefType string `json:"ref_type"` - PusherType PusherType `json:"pusher_type"` - Repo *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the DeletePayload -func (p *DeletePayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload implements Payload -func (p *DeletePayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// ___________ __ -// \_ _____/__________| | __ -// | __)/ _ \_ __ \ |/ / -// | \( <_> ) | \/ < -// \___ / \____/|__| |__|_ \ -// \/ \/ - -// ForkPayload represents fork payload -type ForkPayload struct { - Secret string `json:"secret"` - Forkee *Repository `json:"forkee"` - Repo *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the ForkPayload -func (p *ForkPayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload implements Payload -func (p *ForkPayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// HookIssueCommentAction defines hook issue comment action -type HookIssueCommentAction string - -// all issue comment actions -const ( - HookIssueCommentCreated HookIssueCommentAction = "created" - HookIssueCommentEdited HookIssueCommentAction = "edited" - HookIssueCommentDeleted HookIssueCommentAction = "deleted" -) - -// IssueCommentPayload represents a payload information of issue comment event. -type IssueCommentPayload struct { - Secret string `json:"secret"` - Action HookIssueCommentAction `json:"action"` - Issue *Issue `json:"issue"` - Comment *Comment `json:"comment"` - Changes *ChangesPayload `json:"changes,omitempty"` - Repository *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the IssueCommentPayload -func (p *IssueCommentPayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload implements Payload -func (p *IssueCommentPayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// __________ .__ -// \______ \ ____ | | ____ _____ ______ ____ -// | _// __ \| | _/ __ \\__ \ / ___// __ \ -// | | \ ___/| |_\ ___/ / __ \_\___ \\ ___/ -// |____|_ /\___ >____/\___ >____ /____ >\___ > -// \/ \/ \/ \/ \/ \/ - -// HookReleaseAction defines hook release action type -type HookReleaseAction string - -// all release actions -const ( - HookReleasePublished HookReleaseAction = "published" - HookReleaseUpdated HookReleaseAction = "updated" - HookReleaseDeleted HookReleaseAction = "deleted" -) - -// ReleasePayload represents a payload information of release event. -type ReleasePayload struct { - Secret string `json:"secret"` - Action HookReleaseAction `json:"action"` - Release *Release `json:"release"` - Repository *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the ReleasePayload -func (p *ReleasePayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload implements Payload -func (p *ReleasePayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// __________ .__ -// \______ \__ __ _____| |__ -// | ___/ | \/ ___/ | \ -// | | | | /\___ \| Y \ -// |____| |____//____ >___| / -// \/ \/ - -// PushPayload represents a payload information of push event. -type PushPayload struct { - Secret string `json:"secret"` - Ref string `json:"ref"` - Before string `json:"before"` - After string `json:"after"` - CompareURL string `json:"compare_url"` - Commits []*PayloadCommit `json:"commits"` - HeadCommit *PayloadCommit `json:"head_commit"` - Repo *Repository `json:"repository"` - Pusher *User `json:"pusher"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the PushPayload -func (p *PushPayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload FIXME -func (p *PushPayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// ParsePushHook parses push event hook content. -func ParsePushHook(raw []byte) (*PushPayload, error) { - hook := new(PushPayload) - if err := json.Unmarshal(raw, hook); err != nil { - return nil, err - } - - switch { - case hook.Repo == nil: - return nil, ErrInvalidReceiveHook - case len(hook.Ref) == 0: - return nil, ErrInvalidReceiveHook - } - return hook, nil -} - -// Branch returns branch name from a payload -func (p *PushPayload) Branch() string { - return strings.Replace(p.Ref, "refs/heads/", "", -1) -} - -// .___ -// | | ______ ________ __ ____ -// | |/ ___// ___/ | \_/ __ \ -// | |\___ \ \___ \| | /\ ___/ -// |___/____ >____ >____/ \___ > -// \/ \/ \/ - -// HookIssueAction FIXME -type HookIssueAction string - -const ( - // HookIssueOpened opened - HookIssueOpened HookIssueAction = "opened" - // HookIssueClosed closed - HookIssueClosed HookIssueAction = "closed" - // HookIssueReOpened reopened - HookIssueReOpened HookIssueAction = "reopened" - // HookIssueEdited edited - HookIssueEdited HookIssueAction = "edited" - // HookIssueAssigned assigned - HookIssueAssigned HookIssueAction = "assigned" - // HookIssueUnassigned unassigned - HookIssueUnassigned HookIssueAction = "unassigned" - // HookIssueLabelUpdated label_updated - HookIssueLabelUpdated HookIssueAction = "label_updated" - // HookIssueLabelCleared label_cleared - HookIssueLabelCleared HookIssueAction = "label_cleared" - // HookIssueSynchronized synchronized - HookIssueSynchronized HookIssueAction = "synchronized" - // HookIssueMilestoned is an issue action for when a milestone is set on an issue. - HookIssueMilestoned HookIssueAction = "milestoned" - // HookIssueDemilestoned is an issue action for when a milestone is cleared on an issue. - HookIssueDemilestoned HookIssueAction = "demilestoned" -) - -// IssuePayload represents the payload information that is sent along with an issue event. -type IssuePayload struct { - Secret string `json:"secret"` - Action HookIssueAction `json:"action"` - Index int64 `json:"number"` - Changes *ChangesPayload `json:"changes,omitempty"` - Issue *Issue `json:"issue"` - Repository *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the IssuePayload. -func (p *IssuePayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload encodes the IssuePayload to JSON, with an indentation of two spaces. -func (p *IssuePayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -// ChangesFromPayload FIXME -type ChangesFromPayload struct { - From string `json:"from"` -} - -// ChangesPayload FIXME -type ChangesPayload struct { - Title *ChangesFromPayload `json:"title,omitempty"` - Body *ChangesFromPayload `json:"body,omitempty"` -} - -// __________ .__ .__ __________ __ -// \______ \__ __| | | | \______ \ ____ ________ __ ____ _______/ |_ -// | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\ -// | | | | / |_| |__ | | \ ___< <_| | | /\ ___/ \___ \ | | -// |____| |____/|____/____/ |____|_ /\___ >__ |____/ \___ >____ > |__| -// \/ \/ |__| \/ \/ - -// PullRequestPayload represents a payload information of pull request event. -type PullRequestPayload struct { - Secret string `json:"secret"` - Action HookIssueAction `json:"action"` - Index int64 `json:"number"` - Changes *ChangesPayload `json:"changes,omitempty"` - PullRequest *PullRequest `json:"pull_request"` - Repository *Repository `json:"repository"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the PullRequestPayload. -func (p *PullRequestPayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload FIXME -func (p *PullRequestPayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} - -//__________ .__ __ -//\______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__. -// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | | -// | | \ ___/| |_> > <_> )___ \| || | ( <_> ) | \/\___ | -// |____|_ /\___ > __/ \____/____ >__||__| \____/|__| / ____| -// \/ \/|__| \/ \/ - -// HookRepoAction an action that happens to a repo -type HookRepoAction string - -const ( - // HookRepoCreated created - HookRepoCreated HookRepoAction = "created" - // HookRepoDeleted deleted - HookRepoDeleted HookRepoAction = "deleted" -) - -// RepositoryPayload payload for repository webhooks -type RepositoryPayload struct { - Secret string `json:"secret"` - Action HookRepoAction `json:"action"` - Repository *Repository `json:"repository"` - Organization *User `json:"organization"` - Sender *User `json:"sender"` -} - -// SetSecret modifies the secret of the RepositoryPayload -func (p *RepositoryPayload) SetSecret(secret string) { - p.Secret = secret -} - -// JSONPayload JSON representation of the payload -func (p *RepositoryPayload) JSONPayload() ([]byte, error) { - return json.MarshalIndent(p, "", " ") -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue.go b/vendor/code.gitea.io/sdk/gitea/issue.go deleted file mode 100644 index 0a1defb6f3..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// StateType issue state type -type StateType string - -const ( - // StateOpen pr is opend - StateOpen StateType = "open" - // StateClosed pr is closed - StateClosed StateType = "closed" -) - -// PullRequestMeta PR info if an issue is a PR -type PullRequestMeta struct { - HasMerged bool `json:"merged"` - Merged *time.Time `json:"merged_at"` -} - -// Issue represents an issue in a repository -// swagger:model -type Issue struct { - ID int64 `json:"id"` - URL string `json:"url"` - Index int64 `json:"number"` - Poster *User `json:"user"` - Title string `json:"title"` - Body string `json:"body"` - Labels []*Label `json:"labels"` - Milestone *Milestone `json:"milestone"` - Assignee *User `json:"assignee"` - Assignees []*User `json:"assignees"` - // Whether the issue is open or closed - // - // type: string - // enum: open,closed - State StateType `json:"state"` - Comments int `json:"comments"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - // swagger:strfmt date-time - Updated time.Time `json:"updated_at"` - // swagger:strfmt date-time - Closed *time.Time `json:"closed_at"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` - - PullRequest *PullRequestMeta `json:"pull_request"` -} - -// ListIssueOption list issue options -type ListIssueOption struct { - Page int - State string -} - -// ListIssues returns all issues assigned the authenticated user -func (c *Client) ListIssues(opt ListIssueOption) ([]*Issue, error) { - issues := make([]*Issue, 0, 10) - return issues, c.getParsedResponse("GET", fmt.Sprintf("/issues?page=%d", opt.Page), nil, nil, &issues) -} - -// ListUserIssues returns all issues assigned to the authenticated user -func (c *Client) ListUserIssues(opt ListIssueOption) ([]*Issue, error) { - issues := make([]*Issue, 0, 10) - return issues, c.getParsedResponse("GET", fmt.Sprintf("/user/issues?page=%d", opt.Page), nil, nil, &issues) -} - -// ListRepoIssues returns all issues for a given repository -func (c *Client) ListRepoIssues(owner, repo string, opt ListIssueOption) ([]*Issue, error) { - issues := make([]*Issue, 0, 10) - return issues, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues?page=%d", owner, repo, opt.Page), nil, nil, &issues) -} - -// GetIssue returns a single issue for a given repository -func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) { - issue := new(Issue) - return issue, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), nil, nil, issue) -} - -// CreateIssueOption options to create one issue -type CreateIssueOption struct { - // required:true - Title string `json:"title" binding:"Required"` - Body string `json:"body"` - // username of assignee - Assignee string `json:"assignee"` - Assignees []string `json:"assignees"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` - // milestone id - Milestone int64 `json:"milestone"` - // list of label ids - Labels []int64 `json:"labels"` - Closed bool `json:"closed"` -} - -// CreateIssue create a new issue for a given repository -func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*Issue, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - issue := new(Issue) - return issue, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues", owner, repo), - jsonHeader, bytes.NewReader(body), issue) -} - -// EditIssueOption options for editing an issue -type EditIssueOption struct { - Title string `json:"title"` - Body *string `json:"body"` - Assignee *string `json:"assignee"` - Assignees []string `json:"assignees"` - Milestone *int64 `json:"milestone"` - State *string `json:"state"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` -} - -// EditIssue modify an existing issue for a given repository -func (c *Client) EditIssue(owner, repo string, index int64, opt EditIssueOption) (*Issue, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - issue := new(Issue) - return issue, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), - jsonHeader, bytes.NewReader(body), issue) -} - -// StartIssueStopWatch starts a stopwatch for an existing issue for a given -// repository -func (c *Client) StartIssueStopWatch(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/start", owner, repo, index), - jsonHeader, nil) - return err -} - -// StopIssueStopWatch stops an existing stopwatch for an issue in a given -// repository -func (c *Client) StopIssueStopWatch(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/stopwatch/stop", owner, repo, index), - jsonHeader, nil) - return err -} - -// EditDeadlineOption options for creating a deadline -type EditDeadlineOption struct { - // required:true - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` -} - -// IssueDeadline represents an issue deadline -// swagger:model -type IssueDeadline struct { - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` -} - -// EditPriorityOption options for updating priority -type EditPriorityOption struct { - // required:true - Priority int `json:"priority"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_comment.go b/vendor/code.gitea.io/sdk/gitea/issue_comment.go deleted file mode 100644 index 2c8127c609..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_comment.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Comment represents a comment on a commit or issue -type Comment struct { - ID int64 `json:"id"` - HTMLURL string `json:"html_url"` - PRURL string `json:"pull_request_url"` - IssueURL string `json:"issue_url"` - Poster *User `json:"user"` - Body string `json:"body"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - // swagger:strfmt date-time - Updated time.Time `json:"updated_at"` -} - -// ListIssueComments list comments on an issue. -func (c *Client) ListIssueComments(owner, repo string, index int64) ([]*Comment, error) { - comments := make([]*Comment, 0, 10) - return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), nil, nil, &comments) -} - -// ListRepoIssueComments list comments for a given repo. -func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) { - comments := make([]*Comment, 0, 10) - return comments, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/comments", owner, repo), nil, nil, &comments) -} - -// CreateIssueCommentOption options for creating a comment on an issue -type CreateIssueCommentOption struct { - // required:true - Body string `json:"body" binding:"Required"` -} - -// CreateIssueComment create comment on an issue. -func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateIssueCommentOption) (*Comment, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - comment := new(Comment) - return comment, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/comments", owner, repo, index), jsonHeader, bytes.NewReader(body), comment) -} - -// EditIssueCommentOption options for editing a comment -type EditIssueCommentOption struct { - // required: true - Body string `json:"body" binding:"Required"` -} - -// EditIssueComment edits an issue comment. -func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt EditIssueCommentOption) (*Comment, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - comment := new(Comment) - return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/:%s/:%s/issues/%d/comments/%d", owner, repo, index, commentID), jsonHeader, bytes.NewReader(body), comment) -} - -// DeleteIssueComment deletes an issue comment. -func (c *Client) DeleteIssueComment(owner, repo string, index, commentID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/comments/%d", owner, repo, index, commentID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_label.go b/vendor/code.gitea.io/sdk/gitea/issue_label.go deleted file mode 100644 index 47d1b8221e..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_label.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// Label a label to an issue or a pr -// swagger:model -type Label struct { - ID int64 `json:"id"` - Name string `json:"name"` - // example: 00aabb - Color string `json:"color"` - URL string `json:"url"` -} - -// ListRepoLabels list labels of one repository -func (c *Client) ListRepoLabels(owner, repo string) ([]*Label, error) { - labels := make([]*Label, 0, 10) - return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), nil, nil, &labels) -} - -// GetRepoLabel get one label of repository by repo it -// TODO: maybe we need get a label by name -func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) { - label := new(Label) - return label, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil, label) -} - -// CreateLabelOption options for creating a label -type CreateLabelOption struct { - // required:true - Name string `json:"name" binding:"Required"` - // required:true - // example: #00aabb - Color string `json:"color" binding:"Required;Size(7)"` -} - -// CreateLabel create one label of repository -func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - label := new(Label) - return label, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/labels", owner, repo), - jsonHeader, bytes.NewReader(body), label) -} - -// EditLabelOption options for editing a label -type EditLabelOption struct { - Name *string `json:"name"` - Color *string `json:"color"` -} - -// EditLabel modify one label with options -func (c *Client) EditLabel(owner, repo string, id int64, opt EditLabelOption) (*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - label := new(Label) - return label, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), label) -} - -// DeleteLabel delete one label of repository by id -// TODO: maybe we need delete by name -func (c *Client) DeleteLabel(owner, repo string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/labels/%d", owner, repo, id), nil, nil) - return err -} - -// IssueLabelsOption a collection of labels -type IssueLabelsOption struct { - // list of label IDs - Labels []int64 `json:"labels"` -} - -// GetIssueLabels get labels of one issue via issue id -func (c *Client) GetIssueLabels(owner, repo string, index int64) ([]*Label, error) { - labels := make([]*Label, 0, 5) - return labels, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil, &labels) -} - -// AddIssueLabels add one or more labels to one issue -func (c *Client) AddIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - var labels []*Label - return labels, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels) -} - -// ReplaceIssueLabels replace old labels of issue with new labels -func (c *Client) ReplaceIssueLabels(owner, repo string, index int64, opt IssueLabelsOption) ([]*Label, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - var labels []*Label - return labels, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), jsonHeader, bytes.NewReader(body), &labels) -} - -// DeleteIssueLabel delete one label of one issue by issue id and label id -// TODO: maybe we need delete by label name and issue id -func (c *Client) DeleteIssueLabel(owner, repo string, index, label int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels/%d", owner, repo, index, label), nil, nil) - return err -} - -// ClearIssueLabels delete all the labels of one issue. -func (c *Client) ClearIssueLabels(owner, repo string, index int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/%d/labels", owner, repo, index), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go deleted file mode 100644 index 775a6a9117..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Milestone milestone is a collection of issues on one repository -type Milestone struct { - ID int64 `json:"id"` - Title string `json:"title"` - Description string `json:"description"` - State StateType `json:"state"` - OpenIssues int `json:"open_issues"` - ClosedIssues int `json:"closed_issues"` - // swagger:strfmt date-time - Closed *time.Time `json:"closed_at"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_on"` -} - -// ListRepoMilestones list all the milestones of one repository -func (c *Client) ListRepoMilestones(owner, repo string) ([]*Milestone, error) { - milestones := make([]*Milestone, 0, 10) - return milestones, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), nil, nil, &milestones) -} - -// GetMilestone get one milestone by repo name and milestone id -func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) { - milestone := new(Milestone) - return milestone, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil, milestone) -} - -// CreateMilestoneOption options for creating a milestone -type CreateMilestoneOption struct { - Title string `json:"title"` - Description string `json:"description"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_on"` -} - -// CreateMilestone create one milestone with options -func (c *Client) CreateMilestone(owner, repo string, opt CreateMilestoneOption) (*Milestone, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - milestone := new(Milestone) - return milestone, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/milestones", owner, repo), jsonHeader, bytes.NewReader(body), milestone) -} - -// EditMilestoneOption options for editing a milestone -type EditMilestoneOption struct { - Title string `json:"title"` - Description *string `json:"description"` - State *string `json:"state"` - Deadline *time.Time `json:"due_on"` -} - -// EditMilestone modify milestone with options -func (c *Client) EditMilestone(owner, repo string, id int64, opt EditMilestoneOption) (*Milestone, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - milestone := new(Milestone) - return milestone, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), jsonHeader, bytes.NewReader(body), milestone) -} - -// DeleteMilestone delete one milestone by milestone id -func (c *Client) DeleteMilestone(owner, repo string, id int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/milestones/%d", owner, repo, id), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go deleted file mode 100644 index 7f4b64cbb3..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// TrackedTime worked time for an issue / pr -type TrackedTime struct { - ID int64 `json:"id"` - // swagger:strfmt date-time - Created time.Time `json:"created"` - // Time in seconds - Time int64 `json:"time"` - UserID int64 `json:"user_id"` - IssueID int64 `json:"issue_id"` -} - -// TrackedTimes represent a list of tracked times -type TrackedTimes []*TrackedTime - -// GetUserTrackedTimes list tracked times of a user -func (c *Client) GetUserTrackedTimes(owner, repo, user string) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times/%s", owner, repo, user), nil, nil, ×) -} - -// GetRepoTrackedTimes list tracked times of a repository -func (c *Client) GetRepoTrackedTimes(owner, repo string) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/times", owner, repo), nil, nil, ×) -} - -// GetMyTrackedTimes list tracked times of the current user -func (c *Client) GetMyTrackedTimes() (TrackedTimes, error) { - times := make(TrackedTimes, 0, 10) - return times, c.getParsedResponse("GET", "/user/times", nil, nil, ×) -} - -// AddTimeOption options for adding time to an issue -type AddTimeOption struct { - // time in seconds - // required: true - Time int64 `json:"time" binding:"Required"` -} - -// AddTime adds time to issue with the given index -func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*TrackedTime, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - t := new(TrackedTime) - return t, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), - jsonHeader, bytes.NewReader(body), t) -} - -// ListTrackedTimes get tracked times of one issue via issue id -func (c *Client) ListTrackedTimes(owner, repo string, index int64) (TrackedTimes, error) { - times := make(TrackedTimes, 0, 5) - return times, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/issues/%d/times", owner, repo, index), nil, nil, ×) -} diff --git a/vendor/code.gitea.io/sdk/gitea/lfs_lock.go b/vendor/code.gitea.io/sdk/gitea/lfs_lock.go deleted file mode 100644 index 356636a3a2..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/lfs_lock.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "time" -) - -// LFSLock represent a lock -// for use with the locks API. -type LFSLock struct { - ID string `json:"id"` - Path string `json:"path"` - LockedAt time.Time `json:"locked_at"` - Owner *LFSLockOwner `json:"owner"` -} - -// LFSLockOwner represent a lock owner -// for use with the locks API. -type LFSLockOwner struct { - Name string `json:"name"` -} - -// LFSLockRequest contains the path of the lock to create -// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock -type LFSLockRequest struct { - Path string `json:"path"` -} - -// LFSLockResponse represent a lock created -// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#create-lock -type LFSLockResponse struct { - Lock *LFSLock `json:"lock"` -} - -// LFSLockList represent a list of lock requested -// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks -type LFSLockList struct { - Locks []*LFSLock `json:"locks"` - Next string `json:"next_cursor,omitempty"` -} - -// LFSLockListVerify represent a list of lock verification requested -// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#list-locks-for-verification -type LFSLockListVerify struct { - Ours []*LFSLock `json:"ours"` - Theirs []*LFSLock `json:"theirs"` - Next string `json:"next_cursor,omitempty"` -} - -// LFSLockError contains information on the error that occurs -type LFSLockError struct { - Message string `json:"message"` - Lock *LFSLock `json:"lock,omitempty"` - Documentation string `json:"documentation_url,omitempty"` - RequestID string `json:"request_id,omitempty"` -} - -// LFSLockDeleteRequest contains params of a delete request -// https://github.com/git-lfs/git-lfs/blob/master/docs/api/locking.md#delete-lock -type LFSLockDeleteRequest struct { - Force bool `json:"force"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go b/vendor/code.gitea.io/sdk/gitea/miscellaneous.go deleted file mode 100644 index 3735047b7f..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -// SearchResults results of a successful search -type SearchResults struct { - OK bool `json:"ok"` - Data []*Repository `json:"data"` -} - -// SearchError error of a failed search -type SearchError struct { - OK bool `json:"ok"` - Error string `json:"error"` -} - -// MarkdownOption markdown options -type MarkdownOption struct { - // Text markdown to render - // - // in: body - Text string - // Mode to render - // - // in: body - Mode string - // Context to render - // - // in: body - Context string - // Is it a wiki page ? - // - // in: body - Wiki bool -} - -// MarkdownRender is a rendered markdown document -// swagger:response MarkdownRender -type MarkdownRender string - -// ServerVersion wraps the version of the server -type ServerVersion struct { - Version string `json:"version"` -} - -// ServerVersion returns the version of the server -func (c *Client) ServerVersion() (string, error) { - v := ServerVersion{} - return v.Version, c.getParsedResponse("GET", "/api/v1/version", nil, nil, &v) -} diff --git a/vendor/code.gitea.io/sdk/gitea/org.go b/vendor/code.gitea.io/sdk/gitea/org.go deleted file mode 100644 index 0897da3ef6..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/org.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// Organization represents an organization -type Organization struct { - ID int64 `json:"id"` - UserName string `json:"username"` - FullName string `json:"full_name"` - AvatarURL string `json:"avatar_url"` - Description string `json:"description"` - Website string `json:"website"` - Location string `json:"location"` - Visibility VisibleType `json:"visibility"` -} - -// ListMyOrgs list all of current user's organizations -func (c *Client) ListMyOrgs() ([]*Organization, error) { - orgs := make([]*Organization, 0, 5) - return orgs, c.getParsedResponse("GET", "/user/orgs", nil, nil, &orgs) -} - -// ListUserOrgs list all of some user's organizations -func (c *Client) ListUserOrgs(user string) ([]*Organization, error) { - orgs := make([]*Organization, 0, 5) - return orgs, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/orgs", user), nil, nil, &orgs) -} - -// GetOrg get one organization by name -func (c *Client) GetOrg(orgname string) (*Organization, error) { - org := new(Organization) - return org, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s", orgname), nil, nil, org) -} - -// CreateOrgOption options for creating an organization -type CreateOrgOption struct { - // required: true - UserName string `json:"username" binding:"Required"` - FullName string `json:"full_name"` - Description string `json:"description"` - Website string `json:"website"` - Location string `json:"location"` - Visibility VisibleType `json:"visibility"` -} - -// EditOrgOption options for editing an organization -type EditOrgOption struct { - FullName string `json:"full_name"` - Description string `json:"description"` - Website string `json:"website"` - Location string `json:"location"` -} - -// EditOrg modify one organization via options -func (c *Client) EditOrg(orgname string, opt EditOrgOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s", orgname), jsonHeader, bytes.NewReader(body)) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/org_member.go b/vendor/code.gitea.io/sdk/gitea/org_member.go deleted file mode 100644 index 9bb95af3e2..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/org_member.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// AddOrgMembershipOption add user to organization options -type AddOrgMembershipOption struct { - Role string `json:"role" binding:"Required"` -} - -// AddOrgMembership add some one to an organization's member -func (c *Client) AddOrgMembership(org, user string, opt AddOrgMembershipOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PUT", fmt.Sprintf("/orgs/%s/membership/%s", org, user), jsonHeader, bytes.NewReader(body)) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/org_team.go b/vendor/code.gitea.io/sdk/gitea/org_team.go deleted file mode 100644 index 9de0a8d000..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/org_team.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Copyright 2018 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -// Team represents a team in an organization -type Team struct { - ID int64 `json:"id"` - Name string `json:"name"` - Description string `json:"description"` - Organization *Organization `json:"organization"` - // enum: none,read,write,admin,owner - Permission string `json:"permission"` - // enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki - Units []string `json:"units"` -} - -// CreateTeamOption options for creating a team -type CreateTeamOption struct { - // required: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` - Description string `json:"description" binding:"MaxSize(255)"` - // enum: read,write,admin - Permission string `json:"permission"` - // enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki - Units []string `json:"units"` -} - -// EditTeamOption options for editing a team -type EditTeamOption struct { - // required: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(30)"` - Description string `json:"description" binding:"MaxSize(255)"` - // enum: read,write,admin - Permission string `json:"permission"` - // enum: repo.code,repo.issues,repo.ext_issues,repo.wiki,repo.pulls,repo.releases,repo.ext_wiki - Units []string `json:"units"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/org_type.go b/vendor/code.gitea.io/sdk/gitea/org_type.go deleted file mode 100644 index 778ec3b0a7..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/org_type.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -// VisibleType defines the visibility (Organization only) -type VisibleType int - -const ( - // VisibleTypePublic Visible for everyone - VisibleTypePublic VisibleType = iota - - // VisibleTypeLimited Visible for every connected user - VisibleTypeLimited - - // VisibleTypePrivate Visible only for organization's members - VisibleTypePrivate -) - -// VisibilityModes is a map of org Visibility types -var VisibilityModes = map[string]VisibleType{ - "public": VisibleTypePublic, - "limited": VisibleTypeLimited, - "private": VisibleTypePrivate, -} - -// IsPublic returns true if VisibleType is public -func (vt VisibleType) IsPublic() bool { - return vt == VisibleTypePublic -} - -// IsLimited returns true if VisibleType is limited -func (vt VisibleType) IsLimited() bool { - return vt == VisibleTypeLimited -} - -// IsPrivate returns true if VisibleType is private -func (vt VisibleType) IsPrivate() bool { - return vt == VisibleTypePrivate -} - -// ExtractKeysFromMapString provides a slice of keys from map -func ExtractKeysFromMapString(in map[string]VisibleType) (keys []string) { - for k := range in { - keys = append(keys, k) - } - return -} diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/vendor/code.gitea.io/sdk/gitea/pull.go deleted file mode 100644 index 6fcdd1d41b..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// PullRequest represents a pull request -type PullRequest struct { - ID int64 `json:"id"` - URL string `json:"url"` - Index int64 `json:"number"` - Poster *User `json:"user"` - Title string `json:"title"` - Body string `json:"body"` - Labels []*Label `json:"labels"` - Milestone *Milestone `json:"milestone"` - Assignee *User `json:"assignee"` - Assignees []*User `json:"assignees"` - State StateType `json:"state"` - Comments int `json:"comments"` - - HTMLURL string `json:"html_url"` - DiffURL string `json:"diff_url"` - PatchURL string `json:"patch_url"` - - Mergeable bool `json:"mergeable"` - HasMerged bool `json:"merged"` - // swagger:strfmt date-time - Merged *time.Time `json:"merged_at"` - MergedCommitID *string `json:"merge_commit_sha"` - MergedBy *User `json:"merged_by"` - - Base *PRBranchInfo `json:"base"` - Head *PRBranchInfo `json:"head"` - MergeBase string `json:"merge_base"` - - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` - - // swagger:strfmt date-time - Created *time.Time `json:"created_at"` - // swagger:strfmt date-time - Updated *time.Time `json:"updated_at"` - // swagger:strfmt date-time - Closed *time.Time `json:"closed_at"` -} - -// PRBranchInfo information about a branch -type PRBranchInfo struct { - Name string `json:"label"` - Ref string `json:"ref"` - Sha string `json:"sha"` - RepoID int64 `json:"repo_id"` - Repository *Repository `json:"repo"` -} - -// ListPullRequestsOptions options for listing pull requests -type ListPullRequestsOptions struct { - Page int `json:"page"` - State string `json:"state"` -} - -// ListRepoPullRequests list PRs of one repository -func (c *Client) ListRepoPullRequests(owner, repo string, opt ListPullRequestsOptions) ([]*PullRequest, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - prs := make([]*PullRequest, 0, 10) - return prs, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls", owner, repo), jsonHeader, bytes.NewReader(body), &prs) -} - -// GetPullRequest get information of one PR -func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest, error) { - pr := new(PullRequest) - return pr, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, index), nil, nil, pr) -} - -// CreatePullRequestOption options when creating a pull request -type CreatePullRequestOption struct { - Head string `json:"head" binding:"Required"` - Base string `json:"base" binding:"Required"` - Title string `json:"title" binding:"Required"` - Body string `json:"body"` - Assignee string `json:"assignee"` - Assignees []string `json:"assignees"` - Milestone int64 `json:"milestone"` - Labels []int64 `json:"labels"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` -} - -// CreatePullRequest create pull request with options -func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOption) (*PullRequest, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - pr := new(PullRequest) - return pr, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls", owner, repo), - jsonHeader, bytes.NewReader(body), pr) -} - -// EditPullRequestOption options when modify pull request -type EditPullRequestOption struct { - Title string `json:"title"` - Body string `json:"body"` - Assignee string `json:"assignee"` - Assignees []string `json:"assignees"` - Milestone int64 `json:"milestone"` - Labels []int64 `json:"labels"` - State *string `json:"state"` - // swagger:strfmt date-time - Deadline *time.Time `json:"due_date"` -} - -// EditPullRequest modify pull request with PR id and options -func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRequestOption) (*PullRequest, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - pr := new(PullRequest) - return pr, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), - jsonHeader, bytes.NewReader(body), pr) -} - -// MergePullRequest merge a PR to repository by PR id -func (c *Client) MergePullRequest(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil) - return err -} - -// IsPullRequestMerged test if one PR is merged to one repository -func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, error) { - statusCode, err := c.getStatusCode("GET", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil) - - if err != nil { - return false, err - } - - return statusCode == 204, nil - -} diff --git a/vendor/code.gitea.io/sdk/gitea/release.go b/vendor/code.gitea.io/sdk/gitea/release.go deleted file mode 100644 index 396251dcac..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/release.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2016 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Release represents a repository release -type Release struct { - ID int64 `json:"id"` - TagName string `json:"tag_name"` - Target string `json:"target_commitish"` - Title string `json:"name"` - Note string `json:"body"` - URL string `json:"url"` - TarURL string `json:"tarball_url"` - ZipURL string `json:"zipball_url"` - IsDraft bool `json:"draft"` - IsPrerelease bool `json:"prerelease"` - // swagger:strfmt date-time - CreatedAt time.Time `json:"created_at"` - // swagger:strfmt date-time - PublishedAt time.Time `json:"published_at"` - Publisher *User `json:"author"` - Attachments []*Attachment `json:"assets"` -} - -// ListReleases list releases of a repository -func (c *Client) ListReleases(user, repo string) ([]*Release, error) { - releases := make([]*Release, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases", user, repo), - nil, nil, &releases) - return releases, err -} - -// GetRelease get a release of a repository -func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { - r := new(Release) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), - nil, nil, &r) - return r, err -} - -// CreateReleaseOption options when creating a release -type CreateReleaseOption struct { - // required: true - TagName string `json:"tag_name" binding:"Required"` - Target string `json:"target_commitish"` - Title string `json:"name"` - Note string `json:"body"` - IsDraft bool `json:"draft"` - IsPrerelease bool `json:"prerelease"` -} - -// CreateRelease create a release -func (c *Client) CreateRelease(user, repo string, form CreateReleaseOption) (*Release, error) { - body, err := json.Marshal(form) - if err != nil { - return nil, err - } - r := new(Release) - err = c.getParsedResponse("POST", - fmt.Sprintf("/repos/%s/%s/releases", user, repo), - jsonHeader, bytes.NewReader(body), r) - return r, err -} - -// EditReleaseOption options when editing a release -type EditReleaseOption struct { - TagName string `json:"tag_name"` - Target string `json:"target_commitish"` - Title string `json:"name"` - Note string `json:"body"` - IsDraft *bool `json:"draft"` - IsPrerelease *bool `json:"prerelease"` -} - -// EditRelease edit a release -func (c *Client) EditRelease(user, repo string, id int64, form EditReleaseOption) (*Release, error) { - body, err := json.Marshal(form) - if err != nil { - return nil, err - } - r := new(Release) - err = c.getParsedResponse("PATCH", - fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), - jsonHeader, bytes.NewReader(body), r) - return r, err -} - -// DeleteRelease delete a release from a repository -func (c *Client) DeleteRelease(user, repo string, id int64) error { - _, err := c.getResponse("DELETE", - fmt.Sprintf("/repos/%s/%s/releases/%d", user, repo, id), - nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/vendor/code.gitea.io/sdk/gitea/repo.go deleted file mode 100644 index 8b7c0b1e68..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// Permission represents a set of permissions -type Permission struct { - Admin bool `json:"admin"` - Push bool `json:"push"` - Pull bool `json:"pull"` -} - -// Repository represents a repository -type Repository struct { - ID int64 `json:"id"` - Owner *User `json:"owner"` - Name string `json:"name"` - FullName string `json:"full_name"` - Description string `json:"description"` - Empty bool `json:"empty"` - Private bool `json:"private"` - Fork bool `json:"fork"` - Parent *Repository `json:"parent"` - Mirror bool `json:"mirror"` - Size int `json:"size"` - HTMLURL string `json:"html_url"` - SSHURL string `json:"ssh_url"` - CloneURL string `json:"clone_url"` - Website string `json:"website"` - Stars int `json:"stars_count"` - Forks int `json:"forks_count"` - Watchers int `json:"watchers_count"` - OpenIssues int `json:"open_issues_count"` - DefaultBranch string `json:"default_branch"` - Archived bool `json:"archived"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - // swagger:strfmt date-time - Updated time.Time `json:"updated_at"` - Permissions *Permission `json:"permissions,omitempty"` -} - -// ListMyRepos lists all repositories for the authenticated user that has access to. -func (c *Client) ListMyRepos() ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", "/user/repos", nil, nil, &repos) -} - -// ListUserRepos list all repositories of one user by user's name -func (c *Client) ListUserRepos(user string) ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/repos", user), nil, nil, &repos) -} - -// ListOrgRepos list all repositories of one organization by organization's name -func (c *Client) ListOrgRepos(org string) ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/repos", org), nil, nil, &repos) -} - -// CreateRepoOption options when creating repository -// swagger:model -type CreateRepoOption struct { - // Name of the repository to create - // - // required: true - // unique: true - Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` - // Description of the repository to create - Description string `json:"description" binding:"MaxSize(255)"` - // Whether the repository is private - Private bool `json:"private"` - // Whether the repository should be auto-intialized? - AutoInit bool `json:"auto_init"` - // Gitignores to use - Gitignores string `json:"gitignores"` - // License to use - License string `json:"license"` - // Readme of the repository to create - Readme string `json:"readme"` -} - -// CreateRepo creates a repository for authenticated user. -func (c *Client) CreateRepo(opt CreateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", "/user/repos", jsonHeader, bytes.NewReader(body), repo) -} - -// CreateOrgRepo creates an organization repository for authenticated user. -func (c *Client) CreateOrgRepo(org string, opt CreateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", fmt.Sprintf("/org/%s/repos", org), jsonHeader, bytes.NewReader(body), repo) -} - -// GetRepo returns information of a repository of given owner. -func (c *Client) GetRepo(owner, reponame string) (*Repository, error) { - repo := new(Repository) - return repo, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s", owner, reponame), nil, nil, repo) -} - -// DeleteRepo deletes a repository of user or organization. -func (c *Client) DeleteRepo(owner, repo string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s", owner, repo), nil, nil) - return err -} - -// MigrateRepoOption options for migrating a repository from an external service -type MigrateRepoOption struct { - // required: true - CloneAddr string `json:"clone_addr" binding:"Required"` - AuthUsername string `json:"auth_username"` - AuthPassword string `json:"auth_password"` - // required: true - UID int `json:"uid" binding:"Required"` - // required: true - RepoName string `json:"repo_name" binding:"Required"` - Mirror bool `json:"mirror"` - Private bool `json:"private"` - Description string `json:"description"` -} - -// MigrateRepo migrates a repository from other Git hosting sources for the -// authenticated user. -// -// To migrate a repository for a organization, the authenticated user must be a -// owner of the specified organization. -func (c *Client) MigrateRepo(opt MigrateRepoOption) (*Repository, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - repo := new(Repository) - return repo, c.getParsedResponse("POST", "/repos/migrate", jsonHeader, bytes.NewReader(body), repo) -} - -// MirrorSync adds a mirrored repository to the mirror sync queue. -func (c *Client) MirrorSync(owner, repo string) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/mirror-sync", owner, repo), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_branch.go b/vendor/code.gitea.io/sdk/gitea/repo_branch.go deleted file mode 100644 index 481fc3386e..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_branch.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" -) - -// Branch represents a repository branch -type Branch struct { - Name string `json:"name"` - Commit *PayloadCommit `json:"commit"` -} - -// ListRepoBranches list all the branches of one repository -func (c *Client) ListRepoBranches(user, repo string) ([]*Branch, error) { - branches := make([]*Branch, 0, 10) - return branches, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches", user, repo), nil, nil, &branches) -} - -// GetRepoBranch get one branch's information of one repository -func (c *Client) GetRepoBranch(user, repo, branch string) (*Branch, error) { - b := new(Branch) - return b, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branches/%s", user, repo, branch), nil, nil, &b) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go b/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go deleted file mode 100644 index bd61a22cec..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_collaborator.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" -) - -// ListCollaborators list a repository's collaborators -func (c *Client) ListCollaborators(user, repo string) ([]*User, error) { - collaborators := make([]*User, 0, 10) - err := c.getParsedResponse("GET", - fmt.Sprintf("/repos/%s/%s/collaborators", user, repo), - nil, nil, &collaborators) - return collaborators, err -} - -// IsCollaborator check if a user is a collaborator of a repository -func (c *Client) IsCollaborator(user, repo, collaborator string) (bool, error) { - status, err := c.getStatusCode("GET", - fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), - nil, nil) - if err != nil { - return false, err - } - if status == 204 { - return true, nil - } - return false, nil -} - -// AddCollaboratorOption options when adding a user as a collaborator of a repository -type AddCollaboratorOption struct { - Permission *string `json:"permission"` -} - -// AddCollaborator add some user as a collaborator of a repository -func (c *Client) AddCollaborator(user, repo, collaborator string, opt AddCollaboratorOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), nil, bytes.NewReader(body)) - return err -} - -// DeleteCollaborator remove a collaborator from a repository -func (c *Client) DeleteCollaborator(user, repo, collaborator string) error { - _, err := c.getResponse("DELETE", - fmt.Sprintf("/repos/%s/%s/collaborators/%s", user, repo, collaborator), - nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_commit.go b/vendor/code.gitea.io/sdk/gitea/repo_commit.go deleted file mode 100644 index 1df66428aa..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_commit.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2018 The Gogs Authors. All rights reserved. -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" -) - -// Identity for a person's identity like an author or committer -type Identity struct { - Name string `json:"name" binding:"MaxSize(100)"` - // swagger:strfmt email - Email string `json:"email" binding:"MaxSize(254)"` -} - -// CommitMeta contains meta information of a commit in terms of API. -type CommitMeta struct { - URL string `json:"url"` - SHA string `json:"sha"` -} - -// CommitUser contains information of a user in the context of a commit. -type CommitUser struct { - Identity - Date string `json:"date"` -} - -// RepoCommit contains information of a commit in the context of a repository. -type RepoCommit struct { - URL string `json:"url"` - Author *CommitUser `json:"author"` - Committer *CommitUser `json:"committer"` - Message string `json:"message"` - Tree *CommitMeta `json:"tree"` -} - -// Commit contains information generated from a Git commit. -type Commit struct { - *CommitMeta - HTMLURL string `json:"html_url"` - RepoCommit *RepoCommit `json:"commit"` - Author *User `json:"author"` - Committer *User `json:"committer"` - Parents []*CommitMeta `json:"parents"` -} - -// GetSingleCommit returns a single commit -func (c *Client) GetSingleCommit(user, repo, commitID string) (*Commit, error) { - commit := new(Commit) - return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/commits/%s", user, repo, commitID), nil, nil, &commit) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_file.go b/vendor/code.gitea.io/sdk/gitea/repo_file.go deleted file mode 100644 index 1e9e45ec24..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_file.go +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" -) - -// GetFile downloads a file of repository, ref can be branch/tag/commit. -// e.g.: ref -> master, tree -> macaron.go(no leading slash) -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) -} - -// FileOptions options for all file APIs -type FileOptions struct { - Message string `json:"message" binding:"Required"` - BranchName string `json:"branch"` - NewBranchName string `json:"new_branch"` - Author Identity `json:"author"` - Committer Identity `json:"committer"` -} - -// CreateFileOptions options for creating files -type CreateFileOptions struct { - FileOptions - Content string `json:"content"` -} - -// DeleteFileOptions options for deleting files (used for other File structs below) -type DeleteFileOptions struct { - FileOptions - SHA string `json:"sha" binding:"Required"` -} - -// UpdateFileOptions options for updating files -type UpdateFileOptions struct { - DeleteFileOptions - Content string `json:"content"` - FromPath string `json:"from_path" binding:"MaxSize(500)"` -} - -// FileLinksResponse contains the links for a repo's file -type FileLinksResponse struct { - Self string `json:"url"` - GitURL string `json:"git_url"` - HTMLURL string `json:"html_url"` -} - -// FileContentResponse contains information about a repo's file stats and content -type FileContentResponse struct { - Name string `json:"name"` - Path string `json:"path"` - SHA string `json:"sha"` - Size int64 `json:"size"` - URL string `json:"url"` - HTMLURL string `json:"html_url"` - GitURL string `json:"git_url"` - DownloadURL string `json:"download_url"` - Type string `json:"type"` - Links *FileLinksResponse `json:"_links"` -} - -// FileCommitResponse contains information generated from a Git commit for a repo's file. -type FileCommitResponse struct { - CommitMeta - HTMLURL string `json:"html_url"` - Author *CommitUser `json:"author"` - Committer *CommitUser `json:"committer"` - Parents []*CommitMeta `json:"parents"` - Message string `json:"message"` - Tree *CommitMeta `json:"tree"` -} - -// FileResponse contains information about a repo's file -type FileResponse struct { - Content *FileContentResponse `json:"content"` - Commit *FileCommitResponse `json:"commit"` - Verification *PayloadCommitVerification `json:"verification"` -} - -// FileDeleteResponse contains information about a repo's file that was deleted -type FileDeleteResponse struct { - Content interface{} `json:"content"` // to be set to nil - Commit *FileCommitResponse `json:"commit"` - Verification *PayloadCommitVerification `json:"verification"` -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_key.go b/vendor/code.gitea.io/sdk/gitea/repo_key.go deleted file mode 100644 index a1ae4584e0..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_key.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// DeployKey a deploy key -type DeployKey struct { - ID int64 `json:"id"` - KeyID int64 `json:"key_id"` - Key string `json:"key"` - URL string `json:"url"` - Title string `json:"title"` - Fingerprint string `json:"fingerprint"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - ReadOnly bool `json:"read_only"` - Repository *Repository `json:"repository,omitempty"` -} - -// ListDeployKeys list all the deploy keys of one repository -func (c *Client) ListDeployKeys(user, repo string) ([]*DeployKey, error) { - keys := make([]*DeployKey, 0, 10) - return keys, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys", user, repo), nil, nil, &keys) -} - -// GetDeployKey get one deploy key with key id -func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error) { - key := new(DeployKey) - return key, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/keys/%d", user, repo, keyID), nil, nil, &key) -} - -// CreateKeyOption options when creating a key -type CreateKeyOption struct { - // Title of the key to add - // - // required: true - // unique: true - Title string `json:"title" binding:"Required"` - // An armored SSH key to add - // - // required: true - // unique: true - Key string `json:"key" binding:"Required"` - // Describe if the key has only read access or read/write - // - // required: false - ReadOnly bool `json:"read_only"` -} - -// CreateDeployKey options when create one deploy key -func (c *Client) CreateDeployKey(user, repo string, opt CreateKeyOption) (*DeployKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(DeployKey) - return key, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/keys", user, repo), jsonHeader, bytes.NewReader(body), key) -} - -// DeleteDeployKey delete deploy key with key id -func (c *Client) DeleteDeployKey(owner, repo string, keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/keys/%d", owner, repo, keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_refs.go b/vendor/code.gitea.io/sdk/gitea/repo_refs.go deleted file mode 100644 index b946a10026..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_refs.go +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2018 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "encoding/json" - "errors" - "fmt" - "strings" -) - -// Reference represents a Git reference. -type Reference struct { - Ref string `json:"ref"` - URL string `json:"url"` - Object *GitObject `json:"object"` -} - -// GitObject represents a Git object. -type GitObject struct { - Type string `json:"type"` - SHA string `json:"sha"` - URL string `json:"url"` -} - -// GetRepoRef get one ref's information of one repository -func (c *Client) GetRepoRef(user, repo, ref string) (*Reference, error) { - ref = strings.TrimPrefix(ref, "refs/") - r := new(Reference) - err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil, &r) - if _, ok := err.(*json.UnmarshalTypeError); ok { - // Multiple refs - return nil, errors.New("no exact match found for this ref") - } else if err != nil { - return nil, err - } - - return r, nil -} - -// GetRepoRefs get list of ref's information of one repository -func (c *Client) GetRepoRefs(user, repo, ref string) ([]*Reference, error) { - ref = strings.TrimPrefix(ref, "refs/") - resp, err := c.getResponse("GET", fmt.Sprintf("/repos/%s/%s/git/refs/%s", user, repo, ref), nil, nil) - if err != nil { - return nil, err - } - - // Attempt to unmarshal single returned ref. - r := new(Reference) - refErr := json.Unmarshal(resp, r) - if refErr == nil { - return []*Reference{r}, nil - } - - // Attempt to unmarshal multiple refs. - var rs []*Reference - refsErr := json.Unmarshal(resp, &rs) - if refsErr == nil { - if len(rs) == 0 { - return nil, errors.New("unexpected response: an array of refs with length 0") - } - return rs, nil - } - - return nil, fmt.Errorf("unmarshalling failed for both single and multiple refs: %s and %s", refErr, refsErr) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tag.go b/vendor/code.gitea.io/sdk/gitea/repo_tag.go deleted file mode 100644 index 27efe8da2e..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_tag.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" -) - -// Tag represents a repository tag -type Tag struct { - Name string `json:"name"` - Commit struct { - SHA string `json:"sha"` - URL string `json:"url"` - } `json:"commit"` - ZipballURL string `json:"zipball_url"` - TarballURL string `json:"tarball_url"` -} - -// ListRepoTags list all the branches of one repository -func (c *Client) ListRepoTags(user, repo string) ([]*Tag, error) { - tags := make([]*Tag, 0, 10) - return tags, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/tags", user, repo), nil, nil, &tags) -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tree.go b/vendor/code.gitea.io/sdk/gitea/repo_tree.go deleted file mode 100644 index 842ab9b438..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_tree.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2018 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" -) - -// GitEntry represents a git tree -type GitEntry struct { - Path string `json:"path"` - Mode string `json:"mode"` - Type string `json:"type"` - Size int64 `json:"size"` - SHA string `json:"sha"` - URL string `json:"url"` -} - -// GitTreeResponse returns a git tree -type GitTreeResponse struct { - SHA string `json:"sha"` - URL string `json:"url"` - Entries []GitEntry `json:"tree"` - Truncated bool `json:"truncated"` - Page int `json:"page"` - TotalCount int `json:"total_count"` -} - -// GetTrees downloads a file of repository, ref can be branch/tag/commit. -// e.g.: ref -> master, tree -> macaron.go(no leading slash) -func (c *Client) GetTrees(user, repo, ref string, recursive bool) (*GitTreeResponse, error) { - var trees GitTreeResponse - var path = fmt.Sprintf("/repos/%s/%s/git/trees/%s", user, repo, ref) - if recursive { - path += "?recursive=1" - } - err := c.getParsedResponse("GET", path, nil, nil, &trees) - return &trees, err -} diff --git a/vendor/code.gitea.io/sdk/gitea/repo_watch.go b/vendor/code.gitea.io/sdk/gitea/repo_watch.go deleted file mode 100644 index 1005f9fbd8..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/repo_watch.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "fmt" - "net/http" - "time" -) - -// WatchInfo represents an API watch status of one repository -type WatchInfo struct { - Subscribed bool `json:"subscribed"` - Ignored bool `json:"ignored"` - Reason interface{} `json:"reason"` - CreatedAt time.Time `json:"created_at"` - URL string `json:"url"` - RepositoryURL string `json:"repository_url"` -} - -// GetWatchedRepos list all the watched repos of user -func (c *Client) GetWatchedRepos(user, pass string) ([]*Repository, error) { - repos := make([]*Repository, 0, 10) - return repos, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/subscriptions", user), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, &repos) -} - -// WatchRepo start to watch a repository -func (c *Client) WatchRepo(user, pass, repoUser, repoName string) (*WatchInfo, error) { - i := new(WatchInfo) - return i, c.getParsedResponse("PUT", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, i) -} - -// UnWatchRepo start to watch a repository -func (c *Client) UnWatchRepo(user, pass, repoUser, repoName string) (int, error) { - return c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/subscription", repoUser, repoName), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil) -} diff --git a/vendor/code.gitea.io/sdk/gitea/status.go b/vendor/code.gitea.io/sdk/gitea/status.go deleted file mode 100644 index 3060ab1b2b..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/status.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2017 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// StatusState holds the state of a Status -// It can be "pending", "success", "error", "failure", and "warning" -type StatusState string - -const ( - // StatusPending is for when the Status is Pending - StatusPending StatusState = "pending" - // StatusSuccess is for when the Status is Success - StatusSuccess StatusState = "success" - // StatusError is for when the Status is Error - StatusError StatusState = "error" - // StatusFailure is for when the Status is Failure - StatusFailure StatusState = "failure" - // StatusWarning is for when the Status is Warning - StatusWarning StatusState = "warning" -) - -// Status holds a single Status of a single Commit -type Status struct { - ID int64 `json:"id"` - State StatusState `json:"status"` - TargetURL string `json:"target_url"` - Description string `json:"description"` - URL string `json:"url"` - Context string `json:"context"` - Creator *User `json:"creator"` - // swagger:strfmt date-time - Created time.Time `json:"created_at"` - // swagger:strfmt date-time - Updated time.Time `json:"updated_at"` -} - -// CombinedStatus holds the combined state of several statuses for a single commit -type CombinedStatus struct { - State StatusState `json:"state"` - SHA string `json:"sha"` - TotalCount int `json:"total_count"` - Statuses []*Status `json:"statuses"` - Repository *Repository `json:"repository"` - CommitURL string `json:"commit_url"` - URL string `json:"url"` -} - -// CreateStatusOption holds the information needed to create a new Status for a Commit -type CreateStatusOption struct { - State StatusState `json:"state"` - TargetURL string `json:"target_url"` - Description string `json:"description"` - Context string `json:"context"` -} - -// ListStatusesOption holds pagination information -type ListStatusesOption struct { - Page int -} - -// CreateStatus creates a new Status for a given Commit -// -// POST /repos/:owner/:repo/statuses/:sha -func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) (*Status, error) { - body, err := json.Marshal(&opts) - if err != nil { - return nil, err - } - status := &Status{} - return status, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/statuses/%s", owner, repo, sha), - jsonHeader, bytes.NewReader(body), status) -} - -// ListStatuses returns all statuses for a given Commit -// -// GET /repos/:owner/:repo/commits/:ref/statuses -func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) ([]*Status, error) { - statuses := make([]*Status, 0, 10) - return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?page=%d", owner, repo, sha, opts.Page), nil, nil, &statuses) -} - -// GetCombinedStatus returns the CombinedStatus for a given Commit -// -// GET /repos/:owner/:repo/commits/:ref/status -func (c *Client) GetCombinedStatus(owner, repo, sha string) (*CombinedStatus, error) { - status := &CombinedStatus{} - return status, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/status", owner, repo, sha), nil, nil, status) -} diff --git a/vendor/code.gitea.io/sdk/gitea/user.go b/vendor/code.gitea.io/sdk/gitea/user.go deleted file mode 100644 index 42d9b983e3..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "encoding/json" - "fmt" -) - -// User represents a user -// swagger:model -type User struct { - // the user's id - ID int64 `json:"id"` - // the user's username - UserName string `json:"login"` - // the user's full name - FullName string `json:"full_name"` - // swagger:strfmt email - Email string `json:"email"` - // URL to the user's avatar - AvatarURL string `json:"avatar_url"` - // User locale - Language string `json:"language"` - // Is the user an administrator - IsAdmin bool `json:"is_admin"` -} - -// MarshalJSON implements the json.Marshaler interface for User, adding field(s) for backward compatibility -func (u User) MarshalJSON() ([]byte, error) { - // Re-declaring User to avoid recursion - type shadow User - return json.Marshal(struct { - shadow - CompatUserName string `json:"username"` - }{shadow(u), u.UserName}) -} - -// GetUserInfo get user info by user's name -func (c *Client) GetUserInfo(user string) (*User, error) { - u := new(User) - err := c.getParsedResponse("GET", fmt.Sprintf("/users/%s", user), nil, nil, u) - return u, err -} - -// GetMyUserInfo get user info of current user -func (c *Client) GetMyUserInfo() (*User, error) { - u := new(User) - err := c.getParsedResponse("GET", "/user", nil, nil, u) - return u, err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_app.go b/vendor/code.gitea.io/sdk/gitea/user_app.go deleted file mode 100644 index c5367be5cd..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_app.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2014 The Gogs Authors. All rights reserved. -// Copyright 2019 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/base64" - "encoding/json" - "fmt" - "net/http" -) - -// BasicAuthEncode generate base64 of basic auth head -func BasicAuthEncode(user, pass string) string { - return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass)) -} - -// AccessToken represents an API access token. -// swagger:response AccessToken -type AccessToken struct { - ID int64 `json:"id"` - Name string `json:"name"` - Token string `json:"sha1"` - TokenLastEight string `json:"token_last_eight"` -} - -// AccessTokenList represents a list of API access token. -// swagger:response AccessTokenList -type AccessTokenList []*AccessToken - -// ListAccessTokens lista all the access tokens of user -func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) { - tokens := make([]*AccessToken, 0, 10) - return tokens, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/tokens", user), - http.Header{"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, nil, &tokens) -} - -// CreateAccessTokenOption options when create access token -// swagger:parameters userCreateToken -type CreateAccessTokenOption struct { - Name string `json:"name" binding:"Required"` -} - -// CreateAccessToken create one access token with options -func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOption) (*AccessToken, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - t := new(AccessToken) - return t, c.getParsedResponse("POST", fmt.Sprintf("/users/%s/tokens", user), - http.Header{ - "content-type": []string{"application/json"}, - "Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}}, - bytes.NewReader(body), t) -} - -// DeleteAccessToken delete token with key id -func (c *Client) DeleteAccessToken(user string, keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_email.go b/vendor/code.gitea.io/sdk/gitea/user_email.go deleted file mode 100644 index 721f52144b..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_email.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" -) - -// Email an email address belonging to a user -type Email struct { - // swagger:strfmt email - Email string `json:"email"` - Verified bool `json:"verified"` - Primary bool `json:"primary"` -} - -// ListEmails all the email addresses of user -func (c *Client) ListEmails() ([]*Email, error) { - emails := make([]*Email, 0, 3) - return emails, c.getParsedResponse("GET", "/user/emails", nil, nil, &emails) -} - -// CreateEmailOption options when creating email addresses -type CreateEmailOption struct { - // email addresses to add - Emails []string `json:"emails"` -} - -// AddEmail add one email to current user with options -func (c *Client) AddEmail(opt CreateEmailOption) ([]*Email, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - emails := make([]*Email, 0, 3) - return emails, c.getParsedResponse("POST", "/user/emails", jsonHeader, bytes.NewReader(body), emails) -} - -// DeleteEmailOption options when deleting email addresses -type DeleteEmailOption struct { - // email addresses to delete - Emails []string `json:"emails"` -} - -// DeleteEmail delete one email of current users' -func (c *Client) DeleteEmail(opt DeleteEmailOption) error { - body, err := json.Marshal(&opt) - if err != nil { - return err - } - _, err = c.getResponse("DELETE", "/user/emails", jsonHeader, bytes.NewReader(body)) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_follow.go b/vendor/code.gitea.io/sdk/gitea/user_follow.go deleted file mode 100644 index a197a7f188..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_follow.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import "fmt" - -// ListMyFollowers list all the followers of current user -func (c *Client) ListMyFollowers(page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/user/followers?page=%d", page), nil, nil, &users) -} - -// ListFollowers list all the followers of one user -func (c *Client) ListFollowers(user string, page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/followers?page=%d", user, page), nil, nil, &users) -} - -// ListMyFollowing list all the users current user followed -func (c *Client) ListMyFollowing(page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/user/following?page=%d", page), nil, nil, &users) -} - -// ListFollowing list all the users the user followed -func (c *Client) ListFollowing(user string, page int) ([]*User, error) { - users := make([]*User, 0, 10) - return users, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/following?page=%d", user, page), nil, nil, &users) -} - -// IsFollowing if current user followed the target -func (c *Client) IsFollowing(target string) bool { - _, err := c.getResponse("GET", fmt.Sprintf("/user/following/%s", target), nil, nil) - return err == nil -} - -// IsUserFollowing if the user followed the target -func (c *Client) IsUserFollowing(user, target string) bool { - _, err := c.getResponse("GET", fmt.Sprintf("/users/%s/following/%s", user, target), nil, nil) - return err == nil -} - -// Follow set current user follow the target -func (c *Client) Follow(target string) error { - _, err := c.getResponse("PUT", fmt.Sprintf("/user/following/%s", target), nil, nil) - return err -} - -// Unfollow set current user unfollow the target -func (c *Client) Unfollow(target string) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/following/%s", target), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go deleted file mode 100644 index 0817d89461..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2017 Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// GPGKey a user GPG key to sign commit and tag in repository -type GPGKey struct { - ID int64 `json:"id"` - PrimaryKeyID string `json:"primary_key_id"` - KeyID string `json:"key_id"` - PublicKey string `json:"public_key"` - Emails []*GPGKeyEmail `json:"emails"` - SubsKey []*GPGKey `json:"subkeys"` - CanSign bool `json:"can_sign"` - CanEncryptComms bool `json:"can_encrypt_comms"` - CanEncryptStorage bool `json:"can_encrypt_storage"` - CanCertify bool `json:"can_certify"` - // swagger:strfmt date-time - Created time.Time `json:"created_at,omitempty"` - // swagger:strfmt date-time - Expires time.Time `json:"expires_at,omitempty"` -} - -// GPGKeyEmail an email attached to a GPGKey -// swagger:model GPGKeyEmail -type GPGKeyEmail struct { - Email string `json:"email"` - Verified bool `json:"verified"` -} - -// CreateGPGKeyOption options create user GPG key -type CreateGPGKeyOption struct { - // An armored GPG key to add - // - // required: true - // unique: true - ArmoredKey string `json:"armored_public_key" binding:"Required"` -} - -// ListGPGKeys list all the GPG keys of the user -func (c *Client) ListGPGKeys(user string) ([]*GPGKey, error) { - keys := make([]*GPGKey, 0, 10) - return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/gpg_keys", user), nil, nil, &keys) -} - -// ListMyGPGKeys list all the GPG keys of current user -func (c *Client) ListMyGPGKeys() ([]*GPGKey, error) { - keys := make([]*GPGKey, 0, 10) - return keys, c.getParsedResponse("GET", "/user/gpg_keys", nil, nil, &keys) -} - -// GetGPGKey get current user's GPG key by key id -func (c *Client) GetGPGKey(keyID int64) (*GPGKey, error) { - key := new(GPGKey) - return key, c.getParsedResponse("GET", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil, &key) -} - -// CreateGPGKey create GPG key with options -func (c *Client) CreateGPGKey(opt CreateGPGKeyOption) (*GPGKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(GPGKey) - return key, c.getParsedResponse("POST", "/user/gpg_keys", jsonHeader, bytes.NewReader(body), key) -} - -// DeleteGPGKey delete GPG key with key id -func (c *Client) DeleteGPGKey(keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_key.go b/vendor/code.gitea.io/sdk/gitea/user_key.go deleted file mode 100644 index cccaa65db9..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_key.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "bytes" - "encoding/json" - "fmt" - "time" -) - -// PublicKey publickey is a user key to push code to repository -type PublicKey struct { - ID int64 `json:"id"` - Key string `json:"key"` - URL string `json:"url,omitempty"` - Title string `json:"title,omitempty"` - Fingerprint string `json:"fingerprint,omitempty"` - // swagger:strfmt date-time - Created time.Time `json:"created_at,omitempty"` - Owner *User `json:"user,omitempty"` - ReadOnly bool `json:"read_only,omitempty"` - KeyType string `json:"key_type,omitempty"` -} - -// ListPublicKeys list all the public keys of the user -func (c *Client) ListPublicKeys(user string) ([]*PublicKey, error) { - keys := make([]*PublicKey, 0, 10) - return keys, c.getParsedResponse("GET", fmt.Sprintf("/users/%s/keys", user), nil, nil, &keys) -} - -// ListMyPublicKeys list all the public keys of current user -func (c *Client) ListMyPublicKeys() ([]*PublicKey, error) { - keys := make([]*PublicKey, 0, 10) - return keys, c.getParsedResponse("GET", "/user/keys", nil, nil, &keys) -} - -// GetPublicKey get current user's public key by key id -func (c *Client) GetPublicKey(keyID int64) (*PublicKey, error) { - key := new(PublicKey) - return key, c.getParsedResponse("GET", fmt.Sprintf("/user/keys/%d", keyID), nil, nil, &key) -} - -// CreatePublicKey create public key with options -func (c *Client) CreatePublicKey(opt CreateKeyOption) (*PublicKey, error) { - body, err := json.Marshal(&opt) - if err != nil { - return nil, err - } - key := new(PublicKey) - return key, c.getParsedResponse("POST", "/user/keys", jsonHeader, bytes.NewReader(body), key) -} - -// DeletePublicKey delete public key with key id -func (c *Client) DeletePublicKey(keyID int64) error { - _, err := c.getResponse("DELETE", fmt.Sprintf("/user/keys/%d", keyID), nil, nil) - return err -} diff --git a/vendor/code.gitea.io/sdk/gitea/user_search.go b/vendor/code.gitea.io/sdk/gitea/user_search.go deleted file mode 100644 index 65ab980d66..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/user_search.go +++ /dev/null @@ -1,14 +0,0 @@ -package gitea - -import "fmt" - -type searchUsersResponse struct { - Users []*User `json:"data"` -} - -// SearchUsers finds users by query -func (c *Client) SearchUsers(query string, limit int) ([]*User, error) { - resp := new(searchUsersResponse) - err := c.getParsedResponse("GET", fmt.Sprintf("/users/search?q=%s&limit=%d", query, limit), nil, nil, &resp) - return resp.Users, err -} diff --git a/vendor/code.gitea.io/sdk/gitea/utils.go b/vendor/code.gitea.io/sdk/gitea/utils.go deleted file mode 100644 index 80892a1e7a..0000000000 --- a/vendor/code.gitea.io/sdk/gitea/utils.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Gogs Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package gitea - -import ( - "net/http" -) - -var jsonHeader = http.Header{"content-type": []string{"application/json"}} - -// Bool return address of bool value -func Bool(v bool) *bool { - return &v -} - -// String return address of string value -func String(v string) *string { - return &v -} - -// Int64 return address of int64 value -func Int64(v int64) *int64 { - return &v -} |