diff --git a/internal/archivefiles/archivefiles.go b/internal/archivefiles/archivefiles.go index 7be9e35dd88..4852e977aef 100644 --- a/internal/archivefiles/archivefiles.go +++ b/internal/archivefiles/archivefiles.go @@ -64,9 +64,6 @@ func unique(in []config.File) []config.File { } func destinationFor(f config.File, path string) string { - if f.Destination == "" { - return path - } if f.StripParent { return filepath.Join(f.Destination, filepath.Base(path)) } diff --git a/internal/archivefiles/archivefiles_test.go b/internal/archivefiles/archivefiles_test.go index a67cf4e68f6..3c99662c6e4 100644 --- a/internal/archivefiles/archivefiles_test.go +++ b/internal/archivefiles/archivefiles_test.go @@ -31,6 +31,26 @@ func TestEval(t *testing.T) { }, result) }) + t.Run("strip parent plays nicely with destination omitted", func(t *testing.T) { + result, err := Eval(tmpl, []config.File{{Source: "./testdata/a/b", StripParent: true}}) + + require.NoError(t, err) + require.Equal(t, []config.File{ + {Source: "testdata/a/b/a.txt", Destination: "a.txt"}, + {Source: "testdata/a/b/c/d.txt", Destination: "d.txt"}, + }, result) + }) + + t.Run("strip parent plays nicely with destination as an empty string", func(t *testing.T) { + result, err := Eval(tmpl, []config.File{{Source: "./testdata/a/b", Destination: "", StripParent: true}}) + + require.NoError(t, err) + require.Equal(t, []config.File{ + {Source: "testdata/a/b/a.txt", Destination: "a.txt"}, + {Source: "testdata/a/b/c/d.txt", Destination: "d.txt"}, + }, result) + }) + t.Run("match multiple files within tree without destination", func(t *testing.T) { result, err := Eval(tmpl, []config.File{{Source: "./testdata/a"}}) diff --git a/www/docs/customization/archive.md b/www/docs/customization/archive.md index 83d1ee80105..01645bd88e3 100644 --- a/www/docs/customization/archive.md +++ b/www/docs/customization/archive.md @@ -142,9 +142,6 @@ files: # ... ``` -!!! warning - `strip_parent` is only effective if `dst` is not empty. - ## Packaging only the binaries Since GoReleaser will always add the `README` and `LICENSE` files to the