From 93454de01f92294c49d17d5223e90bd42a325915 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 13 Oct 2019 10:12:46 +0800 Subject: [PATCH 1/2] update dependency package code.gitea.io/sdk/gitea to latest version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7d97c7b..33486a6 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.gitea.io/tea go 1.12 require ( - code.gitea.io/sdk v0.0.0-20190424055801-13a7bf625b83 + code.gitea.io/sdk/gitea v0.0.0-20191013013401-e41e9ea72caa github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7 github.com/mattn/go-runewidth v0.0.4 // indirect github.com/olekukonko/tablewriter v0.0.1 diff --git a/go.sum b/go.sum index 31a19b8..778f38c 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -code.gitea.io/sdk v0.0.0-20190424055801-13a7bf625b83 h1:wrdvJESj8NgPL4tDGNHGAIDOe/rFE8+gIGDwsvC6MuE= -code.gitea.io/sdk v0.0.0-20190424055801-13a7bf625b83/go.mod h1:5bZt0dRznpn2JysytQnV0yCru3FwDv9O5G91jo+lDAk= +code.gitea.io/sdk/gitea v0.0.0-20191013013401-e41e9ea72caa h1:KgpwNF1StxPXMfCD9M++jvCUPUqHPAbuvQn1q3sWtqw= +code.gitea.io/sdk/gitea v0.0.0-20191013013401-e41e9ea72caa/go.mod h1:8IxkM1gyiwEjfO0m47bcmr3u3foR15+LoVub43hCHd0= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= -- 2.40.1 From aceb1f01bd7be79e3ec3c7d16a89eb0a67f638c4 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 13 Oct 2019 11:09:11 +0800 Subject: [PATCH 2/2] update vendor --- vendor/code.gitea.io/sdk/{ => gitea}/LICENSE | 0 vendor/code.gitea.io/sdk/gitea/admin_org.go | 7 + vendor/code.gitea.io/sdk/gitea/admin_user.go | 46 +- vendor/code.gitea.io/sdk/gitea/attachment.go | 27 +- .../sdk/gitea/{gitea.go => client.go} | 2 + vendor/code.gitea.io/sdk/gitea/git_blob.go | 14 - vendor/code.gitea.io/sdk/gitea/git_hook.go | 5 +- vendor/code.gitea.io/sdk/gitea/go.mod | 3 + vendor/code.gitea.io/sdk/gitea/go.sum | 0 vendor/code.gitea.io/sdk/gitea/hook.go | 465 +----------------- vendor/code.gitea.io/sdk/gitea/issue.go | 99 ++-- .../code.gitea.io/sdk/gitea/issue_comment.go | 34 +- vendor/code.gitea.io/sdk/gitea/issue_label.go | 30 +- .../sdk/gitea/issue_milestone.go | 37 +- .../sdk/gitea/issue_tracked_time.go | 25 +- vendor/code.gitea.io/sdk/gitea/lfs_lock.go | 65 --- .../code.gitea.io/sdk/gitea/miscellaneous.go | 45 +- vendor/code.gitea.io/sdk/gitea/org.go | 51 +- vendor/code.gitea.io/sdk/gitea/org_member.go | 2 +- vendor/code.gitea.io/sdk/gitea/org_team.go | 111 ++++- vendor/code.gitea.io/sdk/gitea/org_type.go | 22 - vendor/code.gitea.io/sdk/gitea/pull.go | 73 ++- vendor/code.gitea.io/sdk/gitea/release.go | 33 +- vendor/code.gitea.io/sdk/gitea/repo.go | 128 +++-- vendor/code.gitea.io/sdk/gitea/repo_branch.go | 35 ++ vendor/code.gitea.io/sdk/gitea/repo_commit.go | 7 +- vendor/code.gitea.io/sdk/gitea/repo_file.go | 74 --- vendor/code.gitea.io/sdk/gitea/repo_key.go | 37 +- vendor/code.gitea.io/sdk/gitea/repo_tag.go | 12 +- vendor/code.gitea.io/sdk/gitea/status.go | 38 +- vendor/code.gitea.io/sdk/gitea/user.go | 20 +- vendor/code.gitea.io/sdk/gitea/user_app.go | 11 +- vendor/code.gitea.io/sdk/gitea/user_email.go | 1 - vendor/code.gitea.io/sdk/gitea/user_gpgkey.go | 23 +- vendor/code.gitea.io/sdk/gitea/user_key.go | 29 +- vendor/code.gitea.io/sdk/gitea/utils.go | 26 - vendor/modules.txt | 2 +- 37 files changed, 546 insertions(+), 1093 deletions(-) rename vendor/code.gitea.io/sdk/{ => gitea}/LICENSE (100%) rename vendor/code.gitea.io/sdk/gitea/{gitea.go => client.go} (97%) delete mode 100644 vendor/code.gitea.io/sdk/gitea/git_blob.go create mode 100644 vendor/code.gitea.io/sdk/gitea/go.mod create mode 100644 vendor/code.gitea.io/sdk/gitea/go.sum delete mode 100644 vendor/code.gitea.io/sdk/gitea/lfs_lock.go delete mode 100644 vendor/code.gitea.io/sdk/gitea/utils.go diff --git a/vendor/code.gitea.io/sdk/LICENSE b/vendor/code.gitea.io/sdk/gitea/LICENSE similarity index 100% rename from vendor/code.gitea.io/sdk/LICENSE rename to vendor/code.gitea.io/sdk/gitea/LICENSE diff --git a/vendor/code.gitea.io/sdk/gitea/admin_org.go b/vendor/code.gitea.io/sdk/gitea/admin_org.go index 4071b6f..9023bcf 100644 --- a/vendor/code.gitea.io/sdk/gitea/admin_org.go +++ b/vendor/code.gitea.io/sdk/gitea/admin_org.go @@ -1,4 +1,5 @@ // 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. @@ -10,6 +11,12 @@ import ( "fmt" ) +// AdminListOrgs lists all orgs +func (c *Client) AdminListOrgs() ([]*Organization, error) { + orgs := make([]*Organization, 0, 10) + return orgs, c.getParsedResponse("GET", "/admin/orgs", nil, nil, &orgs) +} + // AdminCreateOrg create an organization func (c *Client) AdminCreateOrg(user string, opt CreateOrgOption) (*Organization, error) { body, err := json.Marshal(&opt) diff --git a/vendor/code.gitea.io/sdk/gitea/admin_user.go b/vendor/code.gitea.io/sdk/gitea/admin_user.go index a4df703..51152dd 100644 --- a/vendor/code.gitea.io/sdk/gitea/admin_user.go +++ b/vendor/code.gitea.io/sdk/gitea/admin_user.go @@ -11,18 +11,20 @@ import ( "fmt" ) +// AdminListUsers lists all users +func (c *Client) AdminListUsers() ([]*User, error) { + users := make([]*User, 0, 10) + return users, c.getParsedResponse("GET", "/admin/users", nil, nil, &users) +} + // 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)"` + SourceID int64 `json:"source_id"` + LoginName string `json:"login_name"` + Username string `json:"username"` + FullName string `json:"full_name"` + Email string `json:"email"` + Password string `json:"password"` MustChangePassword *bool `json:"must_change_password"` SendNotify bool `json:"send_notify"` } @@ -39,16 +41,14 @@ func (c *Client) AdminCreateUser(opt CreateUserOption) (*User, error) { // 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)"` + SourceID int64 `json:"source_id"` + LoginName string `json:"login_name"` + FullName string `json:"full_name"` + Email string `json:"email"` + Password string `json:"password"` MustChangePassword *bool `json:"must_change_password"` - Website string `json:"website" binding:"MaxSize(50)"` - Location string `json:"location" binding:"MaxSize(50)"` + Website string `json:"website"` + Location string `json:"location"` Active *bool `json:"active"` Admin *bool `json:"admin"` AllowGitHook *bool `json:"allow_git_hook"` @@ -74,7 +74,7 @@ func (c *Client) AdminDeleteUser(user string) error { return err } -// AdminCreateUserPublicKey create one user with options +// AdminCreateUserPublicKey adds a public key for the user func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*PublicKey, error) { body, err := json.Marshal(&opt) if err != nil { @@ -83,3 +83,9 @@ func (c *Client) AdminCreateUserPublicKey(user string, opt CreateKeyOption) (*Pu key := new(PublicKey) return key, c.getParsedResponse("POST", fmt.Sprintf("/admin/users/%s/keys", user), jsonHeader, bytes.NewReader(body), key) } + +// AdminDeleteUserPublicKey deletes a user's public key +func (c *Client) AdminDeleteUserPublicKey(user string, keyID int) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/admin/users/%s/keys/%d", user, keyID), nil, nil) + return err +} diff --git a/vendor/code.gitea.io/sdk/gitea/attachment.go b/vendor/code.gitea.io/sdk/gitea/attachment.go index 8c527de..ca45195 100644 --- a/vendor/code.gitea.io/sdk/gitea/attachment.go +++ b/vendor/code.gitea.io/sdk/gitea/attachment.go @@ -14,16 +14,14 @@ import ( ) // 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"` + ID int64 `json:"id"` + Name string `json:"name"` + Size int64 `json:"size"` + DownloadCount int64 `json:"download_count"` + Created time.Time `json:"created_at"` + UUID string `json:"uuid"` + DownloadURL string `json:"browser_download_url"` } // ListReleaseAttachments list release's attachments @@ -69,6 +67,11 @@ func (c *Client) CreateReleaseAttachment(user, repo string, release int64, file return attachment, err } +// EditAttachmentOptions options for editing attachments +type EditAttachmentOptions struct { + Name string `json:"name"` +} + // 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) @@ -84,9 +87,3 @@ func (c *Client) DeleteReleaseAttachment(user, repo string, release int64, id in _, 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/gitea.go b/vendor/code.gitea.io/sdk/gitea/client.go similarity index 97% rename from vendor/code.gitea.io/sdk/gitea/gitea.go rename to vendor/code.gitea.io/sdk/gitea/client.go index fa35e09..606b420 100644 --- a/vendor/code.gitea.io/sdk/gitea/gitea.go +++ b/vendor/code.gitea.io/sdk/gitea/client.go @@ -14,6 +14,8 @@ import ( "strings" ) +var jsonHeader = http.Header{"content-type": []string{"application/json"}} + // Version return the library version func Version() string { return "0.12.3" 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 abdd95a..0000000 --- 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 index d47fe1d..089553f 100644 --- a/vendor/code.gitea.io/sdk/gitea/git_hook.go +++ b/vendor/code.gitea.io/sdk/gitea/git_hook.go @@ -17,11 +17,8 @@ type GitHook struct { 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) { +func (c *Client) ListRepoGitHooks(user, repo string) ([]*GitHook, error) { hooks := make([]*GitHook, 0, 10) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks/git", user, repo), nil, nil, &hooks) } diff --git a/vendor/code.gitea.io/sdk/gitea/go.mod b/vendor/code.gitea.io/sdk/gitea/go.mod new file mode 100644 index 0000000..4143739 --- /dev/null +++ b/vendor/code.gitea.io/sdk/gitea/go.mod @@ -0,0 +1,3 @@ +module code.gitea.io/sdk/gitea + +go 1.12 diff --git a/vendor/code.gitea.io/sdk/gitea/go.sum b/vendor/code.gitea.io/sdk/gitea/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/vendor/code.gitea.io/sdk/gitea/hook.go b/vendor/code.gitea.io/sdk/gitea/hook.go index d36e4d4..59c3eaf 100644 --- a/vendor/code.gitea.io/sdk/gitea/hook.go +++ b/vendor/code.gitea.io/sdk/gitea/hook.go @@ -8,42 +8,30 @@ 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"` + 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"` + Updated time.Time `json:"updated_at"` + 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) { +func (c *Client) ListOrgHooks(org string) ([]*Hook, 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) { +func (c *Client) ListRepoHooks(user, repo string) ([]*Hook, error) { hooks := make([]*Hook, 0, 10) return hooks, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/hooks", user, repo), nil, nil, &hooks) } @@ -62,14 +50,11 @@ func (c *Client) GetRepoHook(user, repo string, id int64) (*Hook, error) { // 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"` + Type string `json:"type"` + Config map[string]string `json:"config"` + Events []string `json:"events"` + BranchFilter string `json:"branch_filter"` + Active bool `json:"active"` } // CreateOrgHook create one hook for an organization, with options @@ -94,9 +79,10 @@ func (c *Client) CreateRepoHook(user, repo string, opt CreateHookOption) (*Hook, // EditHookOption options when modify one hook type EditHookOption struct { - Config map[string]string `json:"config"` - Events []string `json:"events"` - Active *bool `json:"active"` + Config map[string]string `json:"config"` + Events []string `json:"events"` + BranchFilter string `json:"branch_filter"` + Active *bool `json:"active"` } // EditOrgHook modify one hook of an organization, with hook id and options @@ -121,7 +107,7 @@ func (c *Client) EditRepoHook(user, repo string, id int64, opt EditHookOption) e // 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) + _, err := c.getResponse("DELETE", fmt.Sprintf("/orgs/%s/hooks/%d", org, id), nil, nil) return err } @@ -130,414 +116,3 @@ 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 index 0a1defb..35c1a1b 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue.go +++ b/vendor/code.gitea.io/sdk/gitea/issue.go @@ -1,4 +1,5 @@ // Copyright 2016 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. @@ -11,16 +12,6 @@ import ( "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"` @@ -28,33 +19,26 @@ type PullRequestMeta struct { } // 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"` + ID int64 `json:"id"` + URL string `json:"url"` + Index int64 `json:"number"` + Poster *User `json:"user"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + 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"` - + State StateType `json:"state"` + Comments int `json:"comments"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` + Deadline *time.Time `json:"due_date"` PullRequest *PullRequestMeta `json:"pull_request"` } @@ -90,14 +74,12 @@ func (c *Client) GetIssue(owner, repo string, index int64) (*Issue, error) { // CreateIssueOption options to create one issue type CreateIssueOption struct { - // required:true - Title string `json:"title" binding:"Required"` + Title string `json:"title"` 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"` + Assignee string `json:"assignee"` + Assignees []string `json:"assignees"` + Deadline *time.Time `json:"due_date"` // milestone id Milestone int64 `json:"milestone"` // list of label ids @@ -118,14 +100,13 @@ func (c *Client) CreateIssue(owner, repo string, opt CreateIssueOption) (*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"` + Title string `json:"title"` + Body *string `json:"body"` + Assignee *string `json:"assignee"` + Assignees []string `json:"assignees"` + Milestone *int64 `json:"milestone"` + State *string `json:"state"` + Deadline *time.Time `json:"due_date"` } // EditIssue modify an existing issue for a given repository @@ -154,23 +135,3 @@ func (c *Client) StopIssueStopWatch(owner, repo string, index int64) error { 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 index 2c8127c..119f7e5 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_comment.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_comment.go @@ -13,16 +13,16 @@ import ( // 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"` + ID int64 `json:"id"` + HTMLURL string `json:"html_url"` + PRURL string `json:"pull_request_url"` + IssueURL string `json:"issue_url"` + Poster *User `json:"user"` + OriginalAuthor string `json:"original_author"` + OriginalAuthorID int64 `json:"original_author_id"` + Body string `json:"body"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` } // ListIssueComments list comments on an issue. @@ -39,8 +39,7 @@ func (c *Client) ListRepoIssueComments(owner, repo string) ([]*Comment, error) { // CreateIssueCommentOption options for creating a comment on an issue type CreateIssueCommentOption struct { - // required:true - Body string `json:"body" binding:"Required"` + Body string `json:"body"` } // CreateIssueComment create comment on an issue. @@ -55,22 +54,21 @@ func (c *Client) CreateIssueComment(owner, repo string, index int64, opt CreateI // EditIssueCommentOption options for editing a comment type EditIssueCommentOption struct { - // required: true - Body string `json:"body" binding:"Required"` + Body string `json:"body"` } // EditIssueComment edits an issue comment. -func (c *Client) EditIssueComment(owner, repo string, index, commentID int64, opt EditIssueCommentOption) (*Comment, error) { +func (c *Client) EditIssueComment(owner, repo string, 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) + return comment, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/comments/%d", owner, repo, 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) +func (c *Client) DeleteIssueComment(owner, repo string, commentID int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/issues/comments/%d", owner, repo, 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 index 47d1b82..c865062 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_label.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_label.go @@ -11,13 +11,13 @@ import ( ) // 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"` + Color string `json:"color"` + Description string `json:"description"` + URL string `json:"url"` } // ListRepoLabels list labels of one repository @@ -35,11 +35,10 @@ func (c *Client) GetRepoLabel(owner, repo string, id int64) (*Label, error) { // CreateLabelOption options for creating a label type CreateLabelOption struct { - // required:true - Name string `json:"name" binding:"Required"` - // required:true + Name string `json:"name"` // example: #00aabb - Color string `json:"color" binding:"Required;Size(7)"` + Color string `json:"color"` + Description string `json:"description"` } // CreateLabel create one label of repository @@ -55,8 +54,9 @@ func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, // EditLabelOption options for editing a label type EditLabelOption struct { - Name *string `json:"name"` - Color *string `json:"color"` + Name *string `json:"name"` + Color *string `json:"color"` + Description *string `json:"description"` } // EditLabel modify one label with options @@ -76,18 +76,18 @@ func (c *Client) DeleteLabel(owner, repo string, id int64) error { 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) } +// IssueLabelsOption a collection of labels +type IssueLabelsOption struct { + // list of label IDs + Labels []int64 `json:"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) diff --git a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go index 775a6a9..f316e17 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_milestone.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_milestone.go @@ -11,18 +11,28 @@ import ( "time" ) +// StateType issue state type +type StateType string + +const ( + // StateOpen pr is opend + StateOpen StateType = "open" + // StateClosed pr is closed + StateClosed StateType = "closed" + // StateAll is all + StateAll StateType = "all" +) + // 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"` + 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"` + Closed *time.Time `json:"closed_at"` + Deadline *time.Time `json:"due_on"` } // ListRepoMilestones list all the milestones of one repository @@ -39,10 +49,9 @@ func (c *Client) GetMilestone(owner, repo string, id int64) (*Milestone, error) // 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"` + Title string `json:"title"` + Description string `json:"description"` + Deadline *time.Time `json:"due_on"` } // CreateMilestone create one milestone with options diff --git a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go index 7f4b64c..faec0a0 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go @@ -13,8 +13,7 @@ import ( // TrackedTime worked time for an issue / pr type TrackedTime struct { - ID int64 `json:"id"` - // swagger:strfmt date-time + ID int64 `json:"id"` Created time.Time `json:"created"` // Time in seconds Time int64 `json:"time"` @@ -22,32 +21,28 @@ type TrackedTime struct { 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) +func (c *Client) GetUserTrackedTimes(owner, repo, user string) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 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) +func (c *Client) GetRepoTrackedTimes(owner, repo string) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 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) +func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, error) { + times := make([]*TrackedTime, 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"` + Time int64 `json:"time"` } // AddTime adds time to issue with the given index @@ -62,7 +57,7 @@ func (c *Client) AddTime(owner, repo string, index int64, opt AddTimeOption) (*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) +func (c *Client) ListTrackedTimes(owner, repo string, index int64) ([]*TrackedTime, error) { + times := make([]*TrackedTime, 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 356636a..0000000 --- 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 index 3735047..6251bca 100644 --- a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go +++ b/vendor/code.gitea.io/sdk/gitea/miscellaneous.go @@ -4,49 +4,10 @@ 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{} + var v = struct { + Version string `json:"version"` + }{} 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 index 0897da3..4b80361 100644 --- a/vendor/code.gitea.io/sdk/gitea/org.go +++ b/vendor/code.gitea.io/sdk/gitea/org.go @@ -1,4 +1,5 @@ // 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. @@ -12,14 +13,14 @@ import ( // 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"` + 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 string `json:"visibility"` } // ListMyOrgs list all of current user's organizations @@ -42,13 +43,24 @@ func (c *Client) GetOrg(orgname string) (*Organization, error) { // 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"` + UserName string `json:"username"` + FullName string `json:"full_name"` + Description string `json:"description"` + Website string `json:"website"` + Location string `json:"location"` + // possible values are `public` (default), `limited` or `private` + // enum: public,limited,private + Visibility string `json:"visibility"` +} + +// CreateOrg creates an organization +func (c *Client) CreateOrg(opt CreateOrgOption) (*Organization, error) { + body, err := json.Marshal(&opt) + if err != nil { + return nil, err + } + org := new(Organization) + return org, c.getParsedResponse("POST", "/orgs", jsonHeader, bytes.NewReader(body), org) } // EditOrgOption options for editing an organization @@ -57,6 +69,9 @@ type EditOrgOption struct { Description string `json:"description"` Website string `json:"website"` Location string `json:"location"` + // possible values are `public`, `limited` or `private` + // enum: public,limited,private + Visibility string `json:"visibility"` } // EditOrg modify one organization via options @@ -68,3 +83,9 @@ func (c *Client) EditOrg(orgname string, opt EditOrgOption) error { _, err = c.getResponse("PATCH", fmt.Sprintf("/orgs/%s", orgname), jsonHeader, bytes.NewReader(body)) return err } + +// DeleteOrg deletes an organization +func (c *Client) DeleteOrg(orgname string) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/orgs/%s", orgname), nil, nil) + return err +} diff --git a/vendor/code.gitea.io/sdk/gitea/org_member.go b/vendor/code.gitea.io/sdk/gitea/org_member.go index 9bb95af..992e794 100644 --- a/vendor/code.gitea.io/sdk/gitea/org_member.go +++ b/vendor/code.gitea.io/sdk/gitea/org_member.go @@ -12,7 +12,7 @@ import ( // AddOrgMembershipOption add user to organization options type AddOrgMembershipOption struct { - Role string `json:"role" binding:"Required"` + Role string `json:"role"` } // AddOrgMembership add some one to an organization's member diff --git a/vendor/code.gitea.io/sdk/gitea/org_team.go b/vendor/code.gitea.io/sdk/gitea/org_team.go index 9de0a8d..a8d4373 100644 --- a/vendor/code.gitea.io/sdk/gitea/org_team.go +++ b/vendor/code.gitea.io/sdk/gitea/org_team.go @@ -1,10 +1,15 @@ -// Copyright 2016 The Gogs Authors. All rights reserved. -// Copyright 2018 The Gitea 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" +) + // Team represents a team in an organization type Team struct { ID int64 `json:"id"` @@ -13,28 +18,112 @@ type Team struct { 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 + // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] Units []string `json:"units"` } +// ListOrgTeams lists all teams of an organization +func (c *Client) ListOrgTeams(org string) ([]*Team, error) { + teams := make([]*Team, 0, 10) + return teams, c.getParsedResponse("GET", fmt.Sprintf("/orgs/%s/teams", org), nil, nil, &teams) +} + +// ListMyTeams lists all the teams of the current user +func (c *Client) ListMyTeams() ([]*Team, error) { + teams := make([]*Team, 0, 10) + return teams, c.getParsedResponse("GET", "/user/teams", nil, nil, &teams) +} + +// GetTeam gets a team by ID +func (c *Client) GetTeam(id int64) (*Team, error) { + t := new(Team) + return t, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d", id), nil, nil, t) +} + // 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)"` + Name string `json:"name"` + Description string `json:"description"` // 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 + // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] Units []string `json:"units"` } +// CreateTeam creates a team for an organization +func (c *Client) CreateTeam(org string, opt CreateTeamOption) (*Team, error) { + body, err := json.Marshal(&opt) + if err != nil { + return nil, err + } + t := new(Team) + return t, c.getParsedResponse("POST", fmt.Sprintf("/orgs/%s/teams", org), jsonHeader, bytes.NewReader(body), t) +} + // 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)"` + Name string `json:"name"` + Description string `json:"description"` // 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 + // example: ["repo.code","repo.issues","repo.ext_issues","repo.wiki","repo.pulls","repo.releases","repo.ext_wiki"] Units []string `json:"units"` } + +// EditTeam edits a team of an organization +func (c *Client) EditTeam(id int64, opt EditTeamOption) error { + body, err := json.Marshal(&opt) + if err != nil { + return err + } + _, err = c.getResponse("PATCH", fmt.Sprintf("/teams/%d", id), jsonHeader, bytes.NewReader(body)) + return err +} + +// DeleteTeam deletes a team of an organization +func (c *Client) DeleteTeam(id int64) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/teams/%d", id), nil, nil) + return err +} + +// ListTeamMembers lists all members of a team +func (c *Client) ListTeamMembers(id int64) ([]*User, error) { + members := make([]*User, 0, 10) + return members, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/members", id), nil, nil, &members) +} + +// GetTeamMember gets a member of a team +func (c *Client) GetTeamMember(id int64, user string) (*User, error) { + m := new(User) + return m, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/members/%s", id, user), nil, nil, m) +} + +// AddTeamMember adds a member to a team +func (c *Client) AddTeamMember(id int64, user string) error { + _, err := c.getResponse("PUT", fmt.Sprintf("/teams/%d/members/%s", id, user), nil, nil) + return err +} + +// RemoveTeamMember removes a member from a team +func (c *Client) RemoveTeamMember(id int64, user string) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/teams/%d/members/%s", id, user), nil, nil) + return err +} + +// ListTeamRepositories lists all repositories of a team +func (c *Client) ListTeamRepositories(id int64) ([]*Repository, error) { + repos := make([]*Repository, 0, 10) + return repos, c.getParsedResponse("GET", fmt.Sprintf("/teams/%d/repos", id), nil, nil, &repos) +} + +// AddTeamRepository adds a repository to a team +func (c *Client) AddTeamRepository(id int64, org, repo string) error { + _, err := c.getResponse("PUT", fmt.Sprintf("/teams/%d/repos/%s/%s", id, org, repo), nil, nil) + return err +} + +// RemoveTeamRepository removes a repository from a team +func (c *Client) RemoveTeamRepository(id int64, org, repo string) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/teams/%d/repos/%s/%s", id, org, repo), nil, nil) + return err +} diff --git a/vendor/code.gitea.io/sdk/gitea/org_type.go b/vendor/code.gitea.io/sdk/gitea/org_type.go index 778ec3b..930be18 100644 --- a/vendor/code.gitea.io/sdk/gitea/org_type.go +++ b/vendor/code.gitea.io/sdk/gitea/org_type.go @@ -18,28 +18,6 @@ const ( 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 { diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/vendor/code.gitea.io/sdk/gitea/pull.go index 6fcdd1d..0e03a05 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ b/vendor/code.gitea.io/sdk/gitea/pull.go @@ -11,6 +11,15 @@ import ( "time" ) +// 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"` +} + // PullRequest represents a pull request type PullRequest struct { ID int64 `json:"id"` @@ -30,9 +39,8 @@ type PullRequest struct { DiffURL string `json:"diff_url"` PatchURL string `json:"patch_url"` - Mergeable bool `json:"mergeable"` - HasMerged bool `json:"merged"` - // swagger:strfmt date-time + Mergeable bool `json:"mergeable"` + HasMerged bool `json:"merged"` Merged *time.Time `json:"merged_at"` MergedCommitID *string `json:"merge_commit_sha"` MergedBy *User `json:"merged_by"` @@ -41,24 +49,10 @@ type PullRequest struct { 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"` + Created *time.Time `json:"created_at"` + Updated *time.Time `json:"updated_at"` + Closed *time.Time `json:"closed_at"` } // ListPullRequestsOptions options for listing pull requests @@ -85,16 +79,15 @@ func (c *Client) GetPullRequest(owner, repo string, index int64) (*PullRequest, // 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"` + Head string `json:"head"` + Base string `json:"base"` + Title string `json:"title"` + Body string `json:"body"` + Assignee string `json:"assignee"` + Assignees []string `json:"assignees"` + Milestone int64 `json:"milestone"` + Labels []int64 `json:"labels"` + Deadline *time.Time `json:"due_date"` } // CreatePullRequest create pull request with options @@ -110,15 +103,14 @@ func (c *Client) CreatePullRequest(owner, repo string, opt CreatePullRequestOpti // 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"` + 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"` + Deadline *time.Time `json:"due_date"` } // EditPullRequest modify pull request with PR id and options @@ -128,7 +120,7 @@ func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRe return nil, err } pr := new(PullRequest) - return pr, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/issues/%d", owner, repo, index), + return pr, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s/pulls/%d", owner, repo, index), jsonHeader, bytes.NewReader(body), pr) } @@ -147,5 +139,4 @@ func (c *Client) IsPullRequestMerged(owner, repo string, index int64) (bool, 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 index 396251d..20f63f6 100644 --- a/vendor/code.gitea.io/sdk/gitea/release.go +++ b/vendor/code.gitea.io/sdk/gitea/release.go @@ -13,22 +13,20 @@ import ( // 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"` + 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"` + CreatedAt time.Time `json:"created_at"` + PublishedAt time.Time `json:"published_at"` + Publisher *User `json:"author"` + Attachments []*Attachment `json:"assets"` } // ListReleases list releases of a repository @@ -51,8 +49,7 @@ func (c *Client) GetRelease(user, repo string, id int64) (*Release, error) { // CreateReleaseOption options when creating a release type CreateReleaseOption struct { - // required: true - TagName string `json:"tag_name" binding:"Required"` + TagName string `json:"tag_name"` Target string `json:"target_commitish"` Title string `json:"name"` Note string `json:"body"` diff --git a/vendor/code.gitea.io/sdk/gitea/repo.go b/vendor/code.gitea.io/sdk/gitea/repo.go index 8b7c0b1..4556f17 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo.go +++ b/vendor/code.gitea.io/sdk/gitea/repo.go @@ -20,32 +20,40 @@ type Permission struct { // 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"` + 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"` + OriginalURL string `json:"original_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"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` + Permissions *Permission `json:"permissions,omitempty"` + HasIssues bool `json:"has_issues"` + HasWiki bool `json:"has_wiki"` + HasPullRequests bool `json:"has_pull_requests"` + IgnoreWhitespaceConflicts bool `json:"ignore_whitespace_conflicts"` + AllowMerge bool `json:"allow_merge_commits"` + AllowRebase bool `json:"allow_rebase"` + AllowRebaseMerge bool `json:"allow_rebase_explicit"` + AllowSquash bool `json:"allow_squash_merge"` + AvatarURL string `json:"avatar_url"` } // ListMyRepos lists all repositories for the authenticated user that has access to. @@ -67,17 +75,16 @@ func (c *Client) ListOrgRepos(org string) ([]*Repository, error) { } // 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)"` + Name string `json:"name"` // Description of the repository to create - Description string `json:"description" binding:"MaxSize(255)"` + Description string `json:"description"` // Whether the repository is private Private bool `json:"private"` + // Issue Label set to use + IssueLabels string `json:"issue_labels"` // Whether the repository should be auto-intialized? AutoInit bool `json:"auto_init"` // Gitignores to use @@ -114,6 +121,50 @@ func (c *Client) GetRepo(owner, reponame string) (*Repository, error) { return repo, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s", owner, reponame), nil, nil, repo) } +// EditRepoOption options when editing a repository's properties +type EditRepoOption struct { + // name of the repository + Name *string `json:"name,omitempty"` + // a short description of the repository. + Description *string `json:"description,omitempty"` + // a URL with more information about the repository. + Website *string `json:"website,omitempty"` + // either `true` to make the repository private or `false` to make it public. + // Note: you will get a 422 error if the organization restricts changing repository visibility to organization + // owners and a non-owner tries to change the value of private. + Private *bool `json:"private,omitempty"` + // either `true` to enable issues for this repository or `false` to disable them. + HasIssues *bool `json:"has_issues,omitempty"` + // either `true` to enable the wiki for this repository or `false` to disable it. + HasWiki *bool `json:"has_wiki,omitempty"` + // sets the default branch for this repository. + DefaultBranch *string `json:"default_branch,omitempty"` + // either `true` to allow pull requests, or `false` to prevent pull request. + HasPullRequests *bool `json:"has_pull_requests,omitempty"` + // either `true` to ignore whitespace for conflicts, or `false` to not ignore whitespace. `has_pull_requests` must be `true`. + IgnoreWhitespaceConflicts *bool `json:"ignore_whitespace_conflicts,omitempty"` + // either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. `has_pull_requests` must be `true`. + AllowMerge *bool `json:"allow_merge_commits,omitempty"` + // either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. `has_pull_requests` must be `true`. + AllowRebase *bool `json:"allow_rebase,omitempty"` + // either `true` to allow rebase with explicit merge commits (--no-ff), or `false` to prevent rebase with explicit merge commits. `has_pull_requests` must be `true`. + AllowRebaseMerge *bool `json:"allow_rebase_explicit,omitempty"` + // either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. `has_pull_requests` must be `true`. + AllowSquash *bool `json:"allow_squash_merge,omitempty"` + // set to `true` to archive this repository. + Archived *bool `json:"archived,omitempty"` +} + +// EditRepo edit the properties of a repository +func (c *Client) EditRepo(owner, reponame string, opt EditRepoOption) (*Repository, error) { + body, err := json.Marshal(&opt) + if err != nil { + return nil, err + } + repo := new(Repository) + return repo, c.getParsedResponse("PATCH", fmt.Sprintf("/repos/%s/%s", owner, reponame), jsonHeader, bytes.NewReader(body), 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) @@ -122,17 +173,14 @@ func (c *Client) DeleteRepo(owner, repo string) error { // MigrateRepoOption options for migrating a repository from an external service type MigrateRepoOption struct { - // required: true - CloneAddr string `json:"clone_addr" binding:"Required"` + CloneAddr string `json:"clone_addr"` 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"` + UID int `json:"uid"` + RepoName string `json:"repo_name"` + Mirror bool `json:"mirror"` + Private bool `json:"private"` + Description string `json:"description"` } // MigrateRepo migrates a repository from other Git hosting sources for the diff --git a/vendor/code.gitea.io/sdk/gitea/repo_branch.go b/vendor/code.gitea.io/sdk/gitea/repo_branch.go index 481fc33..2c7e811 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_branch.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_branch.go @@ -6,8 +6,43 @@ package gitea import ( "fmt" + "time" ) +// PayloadUser represents the author or committer of a commit +type PayloadUser struct { + // Full name of the commit author + Name string `json:"name"` + 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"` + 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"` +} + // Branch represents a repository branch type Branch struct { Name string `json:"name"` diff --git a/vendor/code.gitea.io/sdk/gitea/repo_commit.go b/vendor/code.gitea.io/sdk/gitea/repo_commit.go index 74c52c0..c22c253 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_commit.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_commit.go @@ -11,9 +11,8 @@ import ( // 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)"` + Name string `json:"name"` + Email string `json:"email"` } // CommitMeta contains meta information of a commit in terms of API. @@ -50,5 +49,5 @@ type Commit struct { // 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/commits/%s", user, repo, commitID), nil, nil, &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 index 1e9e45e..69a32a8 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_file.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_file.go @@ -14,77 +14,3 @@ import ( 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 index a1ae458..29c885e 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_key.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_key.go @@ -13,16 +13,15 @@ import ( // 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"` + 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"` + 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 @@ -37,24 +36,6 @@ func (c *Client) GetDeployKey(user, repo string, keyID int64) (*DeployKey, error 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) diff --git a/vendor/code.gitea.io/sdk/gitea/repo_tag.go b/vendor/code.gitea.io/sdk/gitea/repo_tag.go index 27efe8d..cc9c2e3 100644 --- a/vendor/code.gitea.io/sdk/gitea/repo_tag.go +++ b/vendor/code.gitea.io/sdk/gitea/repo_tag.go @@ -10,13 +10,11 @@ import ( // 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"` + Name string `json:"name"` + ID string `json:"id"` + Commit *CommitMeta `json:"commit"` + ZipballURL string `json:"zipball_url"` + TarballURL string `json:"tarball_url"` } // ListRepoTags list all the branches of one repository diff --git a/vendor/code.gitea.io/sdk/gitea/status.go b/vendor/code.gitea.io/sdk/gitea/status.go index 3060ab1..ba9c18c 100644 --- a/vendor/code.gitea.io/sdk/gitea/status.go +++ b/vendor/code.gitea.io/sdk/gitea/status.go @@ -37,21 +37,8 @@ type Status struct { 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"` + Created time.Time `json:"created_at"` + Updated time.Time `json:"updated_at"` } // CreateStatusOption holds the information needed to create a new Status for a Commit @@ -62,11 +49,6 @@ type CreateStatusOption struct { 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 @@ -80,6 +62,11 @@ func (c *Client) CreateStatus(owner, repo, sha string, opts CreateStatusOption) jsonHeader, bytes.NewReader(body), status) } +// ListStatusesOption holds pagination information +type ListStatusesOption struct { + Page int +} + // ListStatuses returns all statuses for a given Commit // // GET /repos/:owner/:repo/commits/:ref/statuses @@ -88,6 +75,17 @@ func (c *Client) ListStatuses(owner, repo, sha string, opts ListStatusesOption) return statuses, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s/statuses?page=%d", owner, repo, sha, opts.Page), nil, nil, &statuses) } +// 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"` +} + // GetCombinedStatus returns the CombinedStatus for a given Commit // // GET /repos/:owner/:repo/commits/:ref/status diff --git a/vendor/code.gitea.io/sdk/gitea/user.go b/vendor/code.gitea.io/sdk/gitea/user.go index 42d9b98..2433474 100644 --- a/vendor/code.gitea.io/sdk/gitea/user.go +++ b/vendor/code.gitea.io/sdk/gitea/user.go @@ -5,12 +5,11 @@ package gitea import ( - "encoding/json" "fmt" + "time" ) // User represents a user -// swagger:model type User struct { // the user's id ID int64 `json:"id"` @@ -18,24 +17,15 @@ type User struct { UserName string `json:"login"` // the user's full name FullName string `json:"full_name"` - // swagger:strfmt email - Email string `json:"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}) + IsAdmin bool `json:"is_admin"` + LastLogin time.Time `json:"last_login,omitempty"` + Created time.Time `json:"created,omitempty"` } // GetUserInfo get user info by user's name diff --git a/vendor/code.gitea.io/sdk/gitea/user_app.go b/vendor/code.gitea.io/sdk/gitea/user_app.go index 023837f..773dcf3 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_app.go +++ b/vendor/code.gitea.io/sdk/gitea/user_app.go @@ -19,19 +19,13 @@ func BasicAuthEncode(user, pass string) string { } // AccessToken represents an API access token. -// swagger:response AccessToken type AccessToken struct { ID int64 `json:"id"` Name string `json:"name"` - Token string `json:"token"` - HashedToken string `json:"hashed_token"` + 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) @@ -40,9 +34,8 @@ func (c *Client) ListAccessTokens(user, pass string) ([]*AccessToken, error) { } // CreateAccessTokenOption options when create access token -// swagger:parameters userCreateToken type CreateAccessTokenOption struct { - Name string `json:"name" binding:"Required"` + Name string `json:"name"` } // CreateAccessToken create one access token with options diff --git a/vendor/code.gitea.io/sdk/gitea/user_email.go b/vendor/code.gitea.io/sdk/gitea/user_email.go index 721f521..7823db1 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_email.go +++ b/vendor/code.gitea.io/sdk/gitea/user_email.go @@ -11,7 +11,6 @@ import ( // 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"` diff --git a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go index 0817d89..4830525 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go +++ b/vendor/code.gitea.io/sdk/gitea/user_gpgkey.go @@ -23,28 +23,16 @@ type GPGKey struct { 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"` + Created time.Time `json:"created_at,omitempty"` + 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) @@ -63,6 +51,13 @@ func (c *Client) GetGPGKey(keyID int64) (*GPGKey, error) { return key, c.getParsedResponse("GET", fmt.Sprintf("/user/gpg_keys/%d", keyID), nil, nil, &key) } +// CreateGPGKeyOption options create user GPG key +type CreateGPGKeyOption struct { + // An armored GPG key to add + // + ArmoredKey string `json:"armored_public_key"` +} + // CreateGPGKey create GPG key with options func (c *Client) CreateGPGKey(opt CreateGPGKeyOption) (*GPGKey, error) { body, err := json.Marshal(&opt) diff --git a/vendor/code.gitea.io/sdk/gitea/user_key.go b/vendor/code.gitea.io/sdk/gitea/user_key.go index cccaa65..34bbd1a 100644 --- a/vendor/code.gitea.io/sdk/gitea/user_key.go +++ b/vendor/code.gitea.io/sdk/gitea/user_key.go @@ -13,16 +13,15 @@ import ( // 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"` + ID int64 `json:"id"` + Key string `json:"key"` + URL string `json:"url,omitempty"` + Title string `json:"title,omitempty"` + Fingerprint string `json:"fingerprint,omitempty"` + 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 @@ -43,6 +42,16 @@ func (c *Client) GetPublicKey(keyID int64) (*PublicKey, error) { return key, c.getParsedResponse("GET", fmt.Sprintf("/user/keys/%d", keyID), nil, nil, &key) } +// CreateKeyOption options when creating a key +type CreateKeyOption struct { + // Title of the key to add + Title string `json:"title"` + // An armored SSH key to add + Key string `json:"key"` + // Describe if the key has only read access or read/write + ReadOnly bool `json:"read_only"` +} + // CreatePublicKey create public key with options func (c *Client) CreatePublicKey(opt CreateKeyOption) (*PublicKey, error) { body, err := json.Marshal(&opt) 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 80892a1..0000000 --- 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 -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 428b050..3e96440 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# code.gitea.io/sdk v0.0.0-20190424055801-13a7bf625b83 +# code.gitea.io/sdk/gitea v0.0.0-20191013013401-e41e9ea72caa code.gitea.io/sdk/gitea # github.com/go-gitea/yaml v0.0.0-20170812160011-eb3733d160e7 github.com/go-gitea/yaml -- 2.40.1