1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00

fix: artifact.Path should filepath.ToSlash (#4117)

this is needed when we run part of the pipeline on windows, and the rest
on linux, for example, the split build pro feature.

extracted from https://github.com/goreleaser/goreleaser/pull/3795 

+ added tests for relative path thing

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-06-15 23:43:06 -03:00 committed by GitHub
parent e5a0f662fd
commit ef3c42f22e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -358,6 +358,7 @@ func (artifacts *Artifacts) Add(a *Artifact) {
a.Path = rel
}
}
a.Path = filepath.ToSlash(a.Path)
log.WithField("name", a.Name).
WithField("type", a.Type).
WithField("path", a.Path).

View File

@ -20,10 +20,12 @@ var _ fmt.Stringer = Type(0)
func TestAdd(t *testing.T) {
var g errgroup.Group
artifacts := New()
wd, _ := os.Getwd()
for _, a := range []*Artifact{
{
Name: "foo",
Type: UploadableArchive,
Path: filepath.Join(wd, "/foo/bar.tgz"),
},
{
Name: "bar",
@ -46,6 +48,8 @@ func TestAdd(t *testing.T) {
}
require.NoError(t, g.Wait())
require.Len(t, artifacts.List(), 4)
archives := artifacts.Filter(ByType(UploadableArchive)).List()
require.Len(t, archives, 1)
}
func TestFilter(t *testing.T) {