From 24d86475b48dec37a93639d98b65031addb903f7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 29 Nov 2022 21:37:23 -0300 Subject: [PATCH] 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 --- internal/artifact/artifact.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/artifact/artifact.go b/internal/artifact/artifact.go index 2c28d76b613..6afdb160443 100644 --- a/internal/artifact/artifact.go +++ b/internal/artifact/artifact.go @@ -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 }