Skip to content

Commit

Permalink
fix: warn if list has multiple files with same name (#3607)
Browse files Browse the repository at this point in the history
`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>
  • Loading branch information
caarlos0 committed Nov 30, 2022
1 parent 6ff8936 commit 24d8647
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/artifact/artifact.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 24d8647

Please sign in to comment.