From 3c66a7af24db384f0ab677ec3f3db7ce8cff4a01 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Sat, 4 Jan 2020 01:44:33 +0000 Subject: [PATCH] [Vendor] Update gitea go-sdk to 2020-01-03 (#81) update sdk to v0.0.0-20200103062250-c7686bd633c6 Co-authored-by: 6543 <6543@obermui.de> Reviewed-by: techknowlogick Reviewed-by: sapk Reviewed-by: mrsdizzie --- go.mod | 2 +- go.sum | 4 +- vendor/code.gitea.io/sdk/gitea/client.go | 3 +- .../sdk/gitea/issue_tracked_time.go | 16 +++++-- .../code.gitea.io/sdk/gitea/miscellaneous.go | 2 +- vendor/code.gitea.io/sdk/gitea/pull.go | 25 +++++++++-- vendor/code.gitea.io/sdk/gitea/repo_topics.go | 45 +++++++++++++++++++ vendor/modules.txt | 2 +- 8 files changed, 86 insertions(+), 13 deletions(-) create mode 100644 vendor/code.gitea.io/sdk/gitea/repo_topics.go diff --git a/go.mod b/go.mod index ff7280e..8149a95 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module code.gitea.io/tea go 1.12 require ( - code.gitea.io/sdk/gitea v0.0.0-20191013013401-e41e9ea72caa + code.gitea.io/sdk/gitea v0.0.0-20200103062250-c7686bd633c6 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 14cee09..5f320be 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -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= +code.gitea.io/sdk/gitea v0.0.0-20200103062250-c7686bd633c6 h1:SFCUXiw/mg8Luu6+2/X8g4a0NGaT8eClU/bWjCKjs3o= +code.gitea.io/sdk/gitea v0.0.0-20200103062250-c7686bd633c6/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= diff --git a/vendor/code.gitea.io/sdk/gitea/client.go b/vendor/code.gitea.io/sdk/gitea/client.go index 606b420..e9c121f 100644 --- a/vendor/code.gitea.io/sdk/gitea/client.go +++ b/vendor/code.gitea.io/sdk/gitea/client.go @@ -39,9 +39,10 @@ func NewClient(url, token string) *Client { } // NewClientWithHTTP creates an API client with a custom http client -func NewClientWithHTTP(url string, httpClient *http.Client) { +func NewClientWithHTTP(url string, httpClient *http.Client) *Client { client := NewClient(url, "") client.client = httpClient + return client } // SetHTTPClient replaces default http.Client with user given one. 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 faec0a0..0ab00fc 100644 --- a/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go +++ b/vendor/code.gitea.io/sdk/gitea/issue_tracked_time.go @@ -16,9 +16,13 @@ type TrackedTime struct { ID int64 `json:"id"` Created time.Time `json:"created"` // Time in seconds - Time int64 `json:"time"` - UserID int64 `json:"user_id"` - IssueID int64 `json:"issue_id"` + Time int64 `json:"time"` + // deprecated (only for backwards compatibility) + UserID int64 `json:"user_id"` + UserName string `json:"user_name"` + // deprecated (only for backwards compatibility) + IssueID int64 `json:"issue_id"` + Issue *Issue `json:"issue"` } // GetUserTrackedTimes list tracked times of a user @@ -42,7 +46,11 @@ func (c *Client) GetMyTrackedTimes() ([]*TrackedTime, error) { // AddTimeOption options for adding time to an issue type AddTimeOption struct { // time in seconds - Time int64 `json:"time"` + Time int64 `json:"time" binding:"Required"` + // optional + Created time.Time `json:"created"` + // optional + User string `json:"user_name"` } // AddTime adds time to issue with the given index diff --git a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go b/vendor/code.gitea.io/sdk/gitea/miscellaneous.go index 6251bca..fe06ac1 100644 --- a/vendor/code.gitea.io/sdk/gitea/miscellaneous.go +++ b/vendor/code.gitea.io/sdk/gitea/miscellaneous.go @@ -9,5 +9,5 @@ func (c *Client) ServerVersion() (string, error) { var v = struct { Version string `json:"version"` }{} - return v.Version, c.getParsedResponse("GET", "/api/v1/version", nil, nil, &v) + return v.Version, c.getParsedResponse("GET", "/version", nil, nil, &v) } diff --git a/vendor/code.gitea.io/sdk/gitea/pull.go b/vendor/code.gitea.io/sdk/gitea/pull.go index 0e03a05..8d9c524 100644 --- a/vendor/code.gitea.io/sdk/gitea/pull.go +++ b/vendor/code.gitea.io/sdk/gitea/pull.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. @@ -124,10 +125,28 @@ func (c *Client) EditPullRequest(owner, repo string, index int64, opt EditPullRe jsonHeader, bytes.NewReader(body), pr) } +// MergePullRequestOption options when merging a pull request +type MergePullRequestOption struct { + // required: true + // enum: merge,rebase,rebase-merge,squash + Do string `json:"Do" binding:"Required;In(merge,rebase,rebase-merge,squash)"` + MergeTitleField string `json:"MergeTitleField"` + MergeMessageField string `json:"MergeMessageField"` +} + +// MergePullRequestResponse response when merging a pull request +type MergePullRequestResponse struct { +} + // MergePullRequest merge a PR to repository by PR id -func (c *Client) MergePullRequest(owner, repo string, index int64) error { - _, err := c.getResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), nil, nil) - return err +func (c *Client) MergePullRequest(owner, repo string, index int64, opt MergePullRequestOption) (*MergePullRequestResponse, error) { + body, err := json.Marshal(&opt) + if err != nil { + return nil, err + } + response := new(MergePullRequestResponse) + return response, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/pulls/%d/merge", owner, repo, index), + jsonHeader, bytes.NewReader(body), response) } // IsPullRequestMerged test if one PR is merged to one repository diff --git a/vendor/code.gitea.io/sdk/gitea/repo_topics.go b/vendor/code.gitea.io/sdk/gitea/repo_topics.go new file mode 100644 index 0000000..1276a53 --- /dev/null +++ b/vendor/code.gitea.io/sdk/gitea/repo_topics.go @@ -0,0 +1,45 @@ +// Copyright 2016 The Gogs Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package gitea + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// TopicsList represents a list of repo's topics +type TopicsList struct { + Topics []string `json:"topics"` +} + +// ListRepoTopics list all repository's topics +func (c *Client) ListRepoTopics(user, repo string) (*TopicsList, error) { + var list TopicsList + return &list, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/topics", user, repo), nil, nil, &list) +} + +// SetRepoTopics replaces the list of repo's topics +func (c *Client) SetRepoTopics(user, repo, list TopicsList) error { + body, err := json.Marshal(&list) + if err != nil { + return err + } + + _, err = c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/topics", user, repo), nil, bytes.NewReader(body)) + return err +} + +// AddRepoTopic adds a topic to a repo's topics list +func (c *Client) AddRepoTopic(user, repo, topic string) error { + _, err := c.getResponse("PUT", fmt.Sprintf("/repos/%s/%s/topics/%s", user, repo, topic), nil, nil) + return err +} + +// DeleteRepoTopic deletes a topic from repo's topics list +func (c *Client) DeleteRepoTopic(user, repo, topic string) error { + _, err := c.getResponse("DELETE", fmt.Sprintf("/repos/%s/%s/topics/%s", user, repo, topic), nil, nil) + return err +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 8ca4382..b2d6fc6 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,4 +1,4 @@ -# code.gitea.io/sdk/gitea v0.0.0-20191013013401-e41e9ea72caa +# code.gitea.io/sdk/gitea v0.0.0-20200103062250-c7686bd633c6 code.gitea.io/sdk/gitea # github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew/spew