From 946f3078d379b7ac0760b20fa2f2884c2cdeb802 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sat, 18 Feb 2017 14:11:15 -0200 Subject: [PATCH 1/2] Add "mirror" field to repo API --- models/repo.go | 1 + 1 file changed, 1 insertion(+) diff --git a/models/repo.go b/models/repo.go index c79c52d682..e50743109b 100644 --- a/models/repo.go +++ b/models/repo.go @@ -281,6 +281,7 @@ func (repo *Repository) APIFormat(mode AccessMode) *api.Repository { Description: repo.Description, Private: repo.IsPrivate, Fork: repo.IsFork, + Mirror: repo.IsMirror, HTMLURL: repo.HTMLURL(), SSHURL: cloneLink.SSH, CloneURL: cloneLink.HTTPS, From d7af8f96d7f340d83d8ff8d9d94189f92900aef7 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 22 Feb 2017 20:53:33 -0300 Subject: [PATCH 2/2] Update vendor of code.gitea.io/sdk/gitea --- vendor/code.gitea.io/sdk/gitea/hook.go | 29 +++++++- vendor/code.gitea.io/sdk/gitea/issue.go | 1 + vendor/code.gitea.io/sdk/gitea/pull.go | 1 + .../sdk/gitea/{releases.go => release.go} | 0 vendor/code.gitea.io/sdk/gitea/repo.go | 1 + vendor/code.gitea.io/sdk/gitea/user_gpgkey.go | 67 +++++++++++++++++++ vendor/vendor.json | 6 +- 7 files changed, 101 insertions(+), 4 deletions(-) rename vendor/code.gitea.io/sdk/gitea/{releases.go => release.go} (100%) create mode 100644 vendor/code.gitea.io/sdk/gitea/user_gpgkey.go 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 similarity index 100% rename from vendor/code.gitea.io/sdk/gitea/releases.go rename to 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 +} diff --git a/vendor/vendor.json b/vendor/vendor.json index 3a4ebc5780..afe768a0be 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -9,10 +9,10 @@ "revisionTime": "2017-02-22T02:52:05Z" }, { - "checksumSHA1": "BKj0haFTDebzdC2nACpoGzp3s8A=", + "checksumSHA1": "K0VWBaa3ZUE598zVFGavdLB7vW4=", "path": "code.gitea.io/sdk/gitea", - "revision": "2064cc397bc48b0a46f8324a97421a824b11882e", - "revisionTime": "2016-12-31T14:43:27Z" + "revision": "06902fe19508c7ede2be38b71287c665efa1f10d", + "revisionTime": "2017-02-19T11:17:32Z" }, { "checksumSHA1": "IyfS7Rbl6OgR83QR7TOfKdDCq+M=",