1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00

Merge pull request #160 from goreleaser/linter-fixes

fixed several lint errors
This commit is contained in:
Carlos Alexandro Becker 2017-04-09 11:09:51 -03:00 committed by GitHub
commit 77a384812e
3 changed files with 15 additions and 19 deletions

View File

@ -23,12 +23,8 @@ func (Pipe) Description() string {
// Run the pipe
func (Pipe) Run(ctx *context.Context) error {
if ctx.Config.Build.Hooks.Pre != "" {
log.Println("Running pre-build hook", ctx.Config.Build.Hooks.Pre)
cmd := strings.Fields(ctx.Config.Build.Hooks.Pre)
if err := run(runtime.GOOS, runtime.GOARCH, cmd); err != nil {
return err
}
if err := runHook(ctx.Config.Build.Hooks.Pre); err != nil {
return err
}
var g errgroup.Group
for _, goos := range ctx.Config.Build.Goos {
@ -51,14 +47,16 @@ func (Pipe) Run(ctx *context.Context) error {
if err := g.Wait(); err != nil {
return err
}
if ctx.Config.Build.Hooks.Post != "" {
log.Println("Running post-build hook", ctx.Config.Build.Hooks.Post)
cmd := strings.Fields(ctx.Config.Build.Hooks.Post)
if err := run(runtime.GOOS, runtime.GOARCH, cmd); err != nil {
return err
}
return runHook(ctx.Config.Build.Hooks.Post)
}
func runHook(hook string) error {
if hook == "" {
return nil
}
return nil
log.Println("Running hook", hook)
cmd := strings.Fields(hook)
return run(runtime.GOOS, runtime.GOARCH, cmd)
}
func build(name, goos, goarch string, ctx *context.Context) error {
@ -77,10 +75,7 @@ func build(name, goos, goarch string, ctx *context.Context) error {
return err
}
cmd = append(cmd, "-ldflags="+flags, "-o", output, ctx.Config.Build.Main)
if err := run(goos, goarch, cmd); err != nil {
return err
}
return nil
return run(goos, goarch, cmd)
}
func run(goos, goarch string, command []string) error {

View File

@ -24,7 +24,7 @@ func TestValidEnv(t *testing.T) {
func TestInvalidEnv(t *testing.T) {
assert := assert.New(t)
os.Unsetenv("GITHUB_TOKEN")
assert.NoError(os.Unsetenv("GITHUB_TOKEN"))
var ctx = &context.Context{
Config: config.Project{},
}

View File

@ -46,7 +46,8 @@ func (Pipe) Run(ctx *context.Context) (err error) {
}
// removes usual `v` prefix
ctx.Version = strings.TrimPrefix(tag, "v")
if matches, err := regexp.MatchString("^[0-9.]+", ctx.Version); !matches || err != nil {
matches, err := regexp.MatchString("^[0-9.]+", ctx.Version)
if err != nil || !matches {
return ErrInvalidVersionFormat{ctx.Version}
}
commit, err := commitHash()