mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-04 03:11:55 +02:00
refactor: Changed Client.CreateFile to be more generic
The GitHub implementation of CreateFile implicitly uses HomeBrew data. Added parameters for CommitAuthor and Repo so the call site can specify these parameters based on the context.
This commit is contained in:
parent
28dc083b4a
commit
d7107803a3
@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"os"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
)
|
||||
|
||||
@ -18,6 +19,6 @@ type Info struct {
|
||||
// Client interface
|
||||
type Client interface {
|
||||
CreateRelease(ctx *context.Context, body string) (releaseID int64, err error)
|
||||
CreateFile(ctx *context.Context, content bytes.Buffer, path string) (err error)
|
||||
CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo config.Repo, content bytes.Buffer, path string) (err error)
|
||||
Upload(ctx *context.Context, releaseID int64, name string, file *os.File) (err error)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/google/go-github/github"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
@ -39,6 +40,8 @@ func NewGitHub(ctx *context.Context) (Client, error) {
|
||||
|
||||
func (c *githubClient) CreateFile(
|
||||
ctx *context.Context,
|
||||
commitAuthor config.CommitAuthor,
|
||||
repo config.Repo,
|
||||
content bytes.Buffer,
|
||||
path string,
|
||||
) (err error) {
|
||||
|
@ -133,7 +133,7 @@ func doRun(ctx *context.Context, client client.Client) error {
|
||||
log.WithField("formula", path).
|
||||
WithField("repo", ctx.Config.Brew.GitHub.String()).
|
||||
Info("pushing")
|
||||
return client.CreateFile(ctx, content, path)
|
||||
return client.CreateFile(ctx, ctx.Config.Brew.CommitAuthor, ctx.Config.Brew.GitHub, content, path)
|
||||
}
|
||||
|
||||
func buildFormula(ctx *context.Context, client client.Client, artifact artifact.Artifact) (bytes.Buffer, error) {
|
||||
|
@ -391,7 +391,7 @@ func (client *DummyClient) CreateRelease(ctx *context.Context, body string) (rel
|
||||
return
|
||||
}
|
||||
|
||||
func (client *DummyClient) CreateFile(ctx *context.Context, content bytes.Buffer, path string) (err error) {
|
||||
func (client *DummyClient) CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo config.Repo, content bytes.Buffer, path string) (err error) {
|
||||
client.CreatedFile = true
|
||||
bts, _ := ioutil.ReadAll(&content)
|
||||
client.Content = string(bts)
|
||||
|
@ -211,7 +211,7 @@ func (client *DummyClient) CreateRelease(ctx *context.Context, body string) (rel
|
||||
return
|
||||
}
|
||||
|
||||
func (client *DummyClient) CreateFile(ctx *context.Context, content bytes.Buffer, path string) (err error) {
|
||||
func (client *DummyClient) CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo config.Repo, content bytes.Buffer, path string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user