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

fix: warn if list has multiple files with same name (#3607)

`List()` "materializes" the filters, so its used everywhere... if we
have multiple files with the same name there, its likely some filter
wasn't enough, or that the user configuration is faulty. Either way, we
should warn about it to help prevent release issues (like duplicated
assets on github).

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2022-11-29 21:37:23 -03:00 committed by GitHub
parent 6ff89366ca
commit 24d86475b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -289,6 +289,17 @@ func New() Artifacts {
func (artifacts Artifacts) List() []*Artifact {
artifacts.lock.Lock()
defer artifacts.lock.Unlock()
names := map[string]bool{}
for _, item := range artifacts.items {
if item.Name == "" {
continue
}
if names[item.Name] {
log.WithField("name", item.Name).
Warn("multiple artifacts with the same name: this may cause errors")
}
names[item.Name] = true
}
return artifacts.items
}