diff options
author | Andrey Nering <andrey.nering@gmail.com> | 2017-02-22 20:53:33 -0300 |
---|---|---|
committer | Andrey Nering <andrey.nering@gmail.com> | 2017-02-25 10:04:22 -0300 |
commit | d7af8f96d7f340d83d8ff8d9d94189f92900aef7 (patch) | |
tree | 396f75d7024f9bafc385272d7ddd5583811adaf6 /vendor/code.gitea.io | |
parent | 946f3078d379b7ac0760b20fa2f2884c2cdeb802 (diff) | |
download | gitea-d7af8f96d7f340d83d8ff8d9d94189f92900aef7.tar.gz gitea-d7af8f96d7f340d83d8ff8d9d94189f92900aef7.zip |
Update vendor of code.gitea.io/sdk/gitea
Diffstat (limited to 'vendor/code.gitea.io')
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/hook.go | 29 | ||||
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/issue.go | 1 | ||||
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/pull.go | 1 | ||||
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/release.go (renamed from vendor/code.gitea.io/sdk/gitea/releases.go) | 0 | ||||
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/repo.go | 1 | ||||
-rw-r--r-- | vendor/code.gitea.io/sdk/gitea/user_gpgkey.go | 67 |
6 files changed, 98 insertions, 1 deletions
diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/vendor/code.gitea.io/sdk/gitea/hook.go index 4e04275f86..c2f88f4a31 100644 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ b/vendor/code.gitea.io/sdk/gitea/hook.go @@ -1,4 +1,5 @@ // 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. @@ -147,6 +148,7 @@ type PayloadCommit struct { var ( _ Payloader = &CreatePayload{} _ Payloader = &PushPayload{} + _ Payloader = &IssuePayload{} _ Payloader = &PullRequestPayload{} ) @@ -277,8 +279,33 @@ const ( 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"` @@ -308,7 +335,7 @@ type PullRequestPayload struct { Sender *User `json:"sender"` } -// SetSecret FIXME +// SetSecret modifies the secret of the PullRequestPayload. func (p *PullRequestPayload) SetSecret(secret string) { p.Secret = secret } diff --git a/vendor/code.gitea.io/sdk/gitea/issue.go b/vendor/code.gitea.io/sdk/gitea/issue.go index adb283abc2..729e54fe8b 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ b/vendor/code.gitea.io/sdk/gitea/issue.go @@ -30,6 +30,7 @@ type PullRequestMeta struct { // Issue an issue to a repository type Issue struct { ID int64 `json:"id"` + URL string `json:"url"` Index int64 `json:"number"` Poster *User `json:"user"` Title string `json:"title"` diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/vendor/code.gitea.io/sdk/gitea/pull.go index f55ecc042e..fcccf07e2b 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ b/vendor/code.gitea.io/sdk/gitea/pull.go @@ -14,6 +14,7 @@ import ( // PullRequest represents a pull request API object. type PullRequest struct { ID int64 `json:"id"` + URL string `json:"url"` Index int64 `json:"number"` Poster *User `json:"user"` Title string `json:"title"` diff --git a/vendor/code.gitea.io/sdk/gitea/releases.go b/vendor/code.gitea.io/sdk/gitea/release.go index de5ccba342..de5ccba342 100644 --- a/vendor/code.gitea.io/sdk/gitea/releases.go +++ b/vendor/code.gitea.io/sdk/gitea/release.go diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/vendor/code.gitea.io/sdk/gitea/repo.go index 75d6395cb7..9399ca2ee3 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ b/vendor/code.gitea.io/sdk/gitea/repo.go @@ -27,6 +27,7 @@ type Repository struct { Description string `json:"description"` Private bool `json:"private"` Fork bool `json:"fork"` + Mirror bool `json:"mirror"` HTMLURL string `json:"html_url"` SSHURL string `json:"ssh_url"` CloneURL string `json:"clone_url"` diff --git a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go new file mode 100644 index 0000000000..911e63f1a3 --- /dev/null +++ b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go @@ -0,0 +1,67 @@ +// 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"` + Created time.Time `json:"created_at,omitempty"` + Expires time.Time `json:"expires_at,omitempty"` +} + +// GPGKeyEmail a email attache to a GPGKey +type GPGKeyEmail struct { + Email string `json:"email"` + Verified bool `json:"verified"` +} + +// CreateGPGKeyOption options create user GPG key +type CreateGPGKeyOption struct { + ArmoredKey string `json:"armored_public_key" binding:"Required"` +} + +// 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 +} |