Skip to content

Commit

Permalink
fix: clarify scoop no windows error (#3894)
Browse files Browse the repository at this point in the history
improve error message and related docs

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Mar 29, 2023
1 parent 1b86abc commit 37e92ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions internal/pipe/scoop/scoop.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package scoop
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"os"
"path"
Expand All @@ -23,8 +22,13 @@ import (

// ErrNoWindows when there is no build for windows (goos doesn't contain
// windows) or archive.format is binary.
type ErrNoWindows struct {
goamd64 string
}

var ErrNoWindows = errors.New("scoop requires a windows archive\nLearn more at https://goreleaser.com/errors/scoop-archive\n") // nolint: revive
func (e ErrNoWindows) Error() string {
return fmt.Sprintf("scoop requires a windows archive, but no archives matched goos=windows goarch=[386 amd64] goamd64=%s\nLearn more at https://goreleaser.com/errors/scoop-archive\n", e.goamd64) // nolint: revive
}

const scoopConfigExtra = "ScoopConfig"

Expand Down Expand Up @@ -84,7 +88,7 @@ func doRun(ctx *context.Context, cl client.Client) error {
),
).List()
if len(archives) == 0 {
return ErrNoWindows
return ErrNoWindows{scoop.Goamd64}
}

filename := scoop.Name + ".json"
Expand Down
4 changes: 2 additions & 2 deletions internal/pipe/scoop/scoop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func Test_doRun(t *testing.T) {
client.NewMock(),
},
[]artifact.Artifact{},
shouldErr(ErrNoWindows.Error()),
shouldErr(ErrNoWindows{"v1"}.Error()),
shouldNotErr,
noAssertions,
},
Expand Down Expand Up @@ -422,7 +422,7 @@ func Test_doRun(t *testing.T) {
client.NewMock(),
},
[]artifact.Artifact{},
shouldErr(ErrNoWindows.Error()),
shouldErr(ErrNoWindows{"v1"}.Error()),
shouldNotErr,
noAssertions,
},
Expand Down
3 changes: 3 additions & 0 deletions www/docs/errors/scoop-archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ But this would:
archives:
- format: zip
```

Also notice the `goamd64` options, it must match the one from your build.
By default, only `GOAMD64` `v1` is built.

0 comments on commit 37e92ce

Please sign in to comment.