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

fix(build): do not print 'go: downloading' bits of go build output (#4869)

this prevents printing `go: downloading` on go builds in case the mods
weren't previously downloaded...
This commit is contained in:
Carlos Alexandro Becker 2024-05-15 10:13:10 -03:00 committed by GitHub
parent e466507637
commit 9cf3bbbc5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 1 deletions

View File

@ -381,12 +381,23 @@ func run(ctx *context.Context, command, env []string, dir string) error {
if err != nil {
return fmt.Errorf("%w: %s", err, string(out))
}
if s := strings.TrimSpace(string(out)); s != "" {
if s := buildOutput(out); s != "" {
log.Info(s)
}
return nil
}
func buildOutput(out []byte) string {
var lines []string
for _, line := range strings.Split(strings.TrimSpace(string(out)), "\n") {
if strings.HasPrefix(line, "go: downloading") {
continue
}
lines = append(lines, line)
}
return strings.Join(lines, "\n")
}
func checkMain(build config.Build) error {
if build.NoMainCheck {
return nil

View File

@ -1433,6 +1433,25 @@ func TestInvalidGoBinaryTpl(t *testing.T) {
}))
}
func TestBuildOutput(t *testing.T) {
t.Run("empty", func(t *testing.T) {
require.Empty(t, buildOutput([]byte{}))
})
t.Run("downloading only", func(t *testing.T) {
require.Empty(t, buildOutput([]byte(`
go: downloading github.com/atotto/clipboard v0.1.4
go: downloading github.com/caarlos0/duration v0.0.0-20240108180406-5d492514f3c7
`)))
})
t.Run("mixed", func(t *testing.T) {
require.NotEmpty(t, buildOutput([]byte(`
go: downloading github.com/atotto/clipboard v0.1.4
go: downloading github.com/caarlos0/duration v0.0.0-20240108180406-5d492514f3c7
something something
`)))
})
}
//
// Helpers
//