1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-30 04:50:45 +02:00

Revert "chore(deps): bump code.gitea.io/sdk/gitea from v0.12.1 to v0.13.0 (#1806)"

This reverts commit 96dd7c1990b46887f52dae2abc8ce5d40702cc6e.
This commit is contained in:
Carlos Alexandro Becker 2020-09-21 14:23:33 -03:00
parent 9fd5d61dba
commit c28dab5b1d
4 changed files with 45 additions and 25 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.13.0
code.gitea.io/sdk/gitea v0.12.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.13.0 h1:iHognp8ZMhMFLooUUNZFpm8IHaC9qoHJDvAE5vTm5aw=
code.gitea.io/sdk/gitea v0.13.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
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=
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,6 +39,7 @@ 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
@ -46,29 +47,33 @@ func NewGitea(ctx *context.Context, token string) (Client, error) {
},
}
httpClient := &http.Client{Transport: transport}
client, err := gitea.NewClient(instanceURL,
gitea.SetToken(token),
gitea.SetHTTPClient(httpClient),
gitea.SetContext(ctx),
)
if err != nil {
return nil, err
}
client.SetHTTPClient(httpClient)
return &giteaClient{client: client}, nil
}
// CloseMilestone closes a given milestone.
func (c *giteaClient) CloseMilestone(ctx *context.Context, repo Repo, title string) error {
closedState := gitea.StateClosed
opts := gitea.EditMilestoneOption{
State: &closedState,
Title: title,
milestone, err := c.getMilestoneByTitle(repo, title)
if err != nil {
return err
}
_, resp, err := c.client.EditMilestoneByName(repo.Owner, repo.Name, title, opts)
if resp != nil && resp.StatusCode == http.StatusNotFound {
if milestone == nil {
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
}
@ -100,7 +105,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(),
@ -112,7 +117,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
}
@ -141,7 +146,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(),
@ -208,9 +213,27 @@ 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,10 +120,7 @@ func (s *GiteaReleasesTestSuite) SetupTest() {
}
s.releaseID = 666
s.releaseURL = fmt.Sprintf("%v/%v", s.releasesURL, s.releaseID)
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}
s.client = &giteaClient{client: gitea.NewClient(s.url, "")}
}
func (s *GiteaReleasesTestSuite) TearDownTest() {