1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-29 01:44:39 +02:00

fix: nfpm id (#1030)

* fix: nfpm id

* fix: import order
This commit is contained in:
Carlos Alexandro Becker 2019-05-29 09:13:52 -03:00 committed by GitHub
parent 7e809382df
commit d355350f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/apex/log"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/ids"
"github.com/goreleaser/goreleaser/internal/linux"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
@ -71,6 +72,7 @@ func (Pipe) Default(ctx *context.Context) error {
deprecate.Notice("snapcraft")
}
}
var ids = ids.New()
for i := range ctx.Config.Snapcrafts {
var snap = &ctx.Config.Snapcrafts[i]
if snap.NameTemplate == "" {
@ -81,8 +83,9 @@ func (Pipe) Default(ctx *context.Context) error {
snap.Builds = append(snap.Builds, b.ID)
}
}
ids.Inc(snap.ID)
}
return nil
return ids.Validate()
}
// Run the pipe

View File

@ -12,6 +12,7 @@ import (
"github.com/goreleaser/goreleaser/pkg/config"
"github.com/goreleaser/goreleaser/pkg/context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
yaml "gopkg.in/yaml.v2"
)
@ -313,3 +314,19 @@ func addBinaries(t *testing.T, ctx *context.Context, name, dist, dest string) {
}
}
}
func TestSeveralSnapssWithTheSameID(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{
Snapcrafts: []config.Snapcraft{
{
ID: "a",
},
{
ID: "a",
},
},
},
}
require.EqualError(t, Pipe{}.Default(ctx), "found 2 items with the ID 'a', please fix your config")
}

View File

@ -226,6 +226,7 @@ type Snapcraft struct {
Replacements map[string]string `yaml:",omitempty"`
Publish bool `yaml:",omitempty"`
ID string `yaml:",omitempty"`
Builds []string `yaml:",omitempty"`
Name string `yaml:",omitempty"`
Summary string `yaml:",omitempty"`

View File

@ -20,6 +20,10 @@ Available options:
# .goreleaser.yml
snapcrafts:
-
# ID of the nfpm config, must be unique.
# Defaults to "default".
id: foo
# Build IDs for the builds you want to create snapcraft packages for.
# Defaults to all builds.
builds: