1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-29 01:44:39 +02:00

chore(deps): bump code.gitea.io/sdk/gitea from v0.12.1 to v0.13.1 (#1828)

* chore(deps): bump code.gitea.io/sdk/gitea from v0.12.1 to v0.13.1

* only set Context if not nil
This commit is contained in:
6543 2020-10-02 04:06:21 +02:00 committed by GitHub
parent c55267f49f
commit 1bb832a764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 45 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/goreleaser/goreleaser
go 1.15
require (
code.gitea.io/sdk/gitea v0.12.1
code.gitea.io/sdk/gitea v0.13.1
github.com/Masterminds/semver/v3 v3.1.0
github.com/apex/log v1.9.0
github.com/caarlos0/ctrlc v1.0.0

4
go.sum
View File

@ -40,8 +40,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.9.0 h1:oXnZyBjHB6hC8TnSle0AWW6pGJ29EuSo5ww+SFmdNBg=
cloud.google.com/go/storage v1.9.0/go.mod h1:m+/etGaqZbylxaNT876QGXqEHp4PR2Rq5GMqICWb9bU=
code.gitea.io/sdk/gitea v0.12.1 h1:bMgjEqPnNX/i6TpVwXwpjJtFOnUSuC9P6yy/jjy8sjY=
code.gitea.io/sdk/gitea v0.12.1/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
code.gitea.io/sdk/gitea v0.13.1 h1:Y7bpH2iO6Q0KhhMJfjP/LZ0AmiYITeRQlCD8b0oYqhk=
code.gitea.io/sdk/gitea v0.13.1/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
contrib.go.opencensus.io/exporter/aws v0.0.0-20181029163544-2befc13012d0/go.mod h1:uu1P0UCM/6RbsMrgPa98ll8ZcHM858i/AD06a9aLRCA=
contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw=
contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=

View File

@ -39,7 +39,6 @@ func NewGitea(ctx *context.Context, token string) (Client, error) {
if err != nil {
return nil, err
}
client := gitea.NewClient(instanceURL, token)
transport := &http.Transport{
TLSClientConfig: &tls.Config{
// nolint: gosec
@ -47,33 +46,31 @@ func NewGitea(ctx *context.Context, token string) (Client, error) {
},
}
httpClient := &http.Client{Transport: transport}
client.SetHTTPClient(httpClient)
client, err := gitea.NewClient(instanceURL,
gitea.SetToken(token),
gitea.SetHTTPClient(httpClient),
)
if err != nil {
return nil, err
}
if ctx != nil {
gitea.SetContext(ctx)(client)
}
return &giteaClient{client: client}, nil
}
// CloseMilestone closes a given milestone.
func (c *giteaClient) CloseMilestone(ctx *context.Context, repo Repo, title string) error {
milestone, err := c.getMilestoneByTitle(repo, title)
if err != nil {
return err
closedState := gitea.StateClosed
opts := gitea.EditMilestoneOption{
State: &closedState,
Title: title,
}
if milestone == nil {
_, resp, err := c.client.EditMilestoneByName(repo.Owner, repo.Name, title, opts)
if resp != nil && resp.StatusCode == http.StatusNotFound {
return ErrNoMilestoneFound{Title: title}
}
closedState := string(gitea.StateClosed)
opts := gitea.EditMilestoneOption{
Deadline: milestone.Deadline,
Description: &milestone.Description,
State: &closedState,
Title: milestone.Title,
}
_, err = c.client.EditMilestone(repo.Owner, repo.Name, milestone.ID, opts)
return err
}
@ -105,7 +102,7 @@ func (c *giteaClient) createRelease(ctx *context.Context, title, body string) (*
IsDraft: releaseConfig.Draft,
IsPrerelease: ctx.PreRelease,
}
release, err := c.client.CreateRelease(owner, repoName, opts)
release, _, err := c.client.CreateRelease(owner, repoName, opts)
if err != nil {
log.WithFields(log.Fields{
"err": err.Error(),
@ -117,7 +114,7 @@ func (c *giteaClient) createRelease(ctx *context.Context, title, body string) (*
}
func (c *giteaClient) getExistingRelease(owner, repoName, tagName string) (*gitea.Release, error) {
releases, err := c.client.ListReleases(owner, repoName, gitea.ListReleasesOptions{})
releases, _, err := c.client.ListReleases(owner, repoName, gitea.ListReleasesOptions{})
if err != nil {
return nil, err
}
@ -146,7 +143,7 @@ func (c *giteaClient) updateRelease(ctx *context.Context, title, body string, id
IsPrerelease: &ctx.PreRelease,
}
release, err := c.client.EditRelease(owner, repoName, id, opts)
release, _, err := c.client.EditRelease(owner, repoName, id, opts)
if err != nil {
log.WithFields(log.Fields{
"err": err.Error(),
@ -213,27 +210,9 @@ func (c *giteaClient) Upload(
owner := releaseConfig.Gitea.Owner
repoName := releaseConfig.Gitea.Name
_, err = c.client.CreateReleaseAttachment(owner, repoName, giteaReleaseID, file, artifact.Name)
_, _, err = c.client.CreateReleaseAttachment(owner, repoName, giteaReleaseID, file, artifact.Name)
if err != nil {
return RetriableError{err}
}
return nil
}
// getMilestoneByTitle returns a milestone by title.
func (c *giteaClient) getMilestoneByTitle(repo Repo, title string) (*gitea.Milestone, error) {
// The Gitea API/SDK does not provide lookup by title functionality currently.
milestones, err := c.client.ListRepoMilestones(repo.Owner, repo.Name, gitea.ListMilestoneOption{})
if err != nil {
return nil, err
}
for _, milestone := range milestones {
if milestone.Title == title {
return milestone, nil
}
}
return nil, nil
}

View File

@ -120,7 +120,10 @@ func (s *GiteaReleasesTestSuite) SetupTest() {
}
s.releaseID = 666
s.releaseURL = fmt.Sprintf("%v/%v", s.releasesURL, s.releaseID)
s.client = &giteaClient{client: gitea.NewClient(s.url, "")}
httpmock.RegisterResponder("GET", fmt.Sprintf("%s/api/v1/version", s.url), httpmock.NewStringResponder(200, "{\"version\":\"1.12.0\"}"))
newClient, err := gitea.NewClient(s.url)
assert.NoError(s.T(), err)
s.client = &giteaClient{client: newClient}
}
func (s *GiteaReleasesTestSuite) TearDownTest() {