You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-06 09:09:29 +02:00
fix(archive): always strip parent if set (#3256)
* Always strip parents. * refactor: improve code a bit Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> * refactor: even simpler Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com> Co-authored-by: Nathan Hammond <nathan.hammond@vercel.com>
This commit is contained in:
committed by
GitHub
parent
a02bcef337
commit
315935aedc
@@ -64,9 +64,6 @@ func unique(in []config.File) []config.File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func destinationFor(f config.File, path string) string {
|
func destinationFor(f config.File, path string) string {
|
||||||
if f.Destination == "" {
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
if f.StripParent {
|
if f.StripParent {
|
||||||
return filepath.Join(f.Destination, filepath.Base(path))
|
return filepath.Join(f.Destination, filepath.Base(path))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,26 @@ func TestEval(t *testing.T) {
|
|||||||
}, result)
|
}, 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) {
|
t.Run("match multiple files within tree without destination", func(t *testing.T) {
|
||||||
result, err := Eval(tmpl, []config.File{{Source: "./testdata/a"}})
|
result, err := Eval(tmpl, []config.File{{Source: "./testdata/a"}})
|
||||||
|
|
||||||
|
|||||||
@@ -142,9 +142,6 @@ files:
|
|||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
!!! warning
|
|
||||||
`strip_parent` is only effective if `dst` is not empty.
|
|
||||||
|
|
||||||
## Packaging only the binaries
|
## Packaging only the binaries
|
||||||
|
|
||||||
Since GoReleaser will always add the `README` and `LICENSE` files to the
|
Since GoReleaser will always add the `README` and `LICENSE` files to the
|
||||||
|
|||||||
Reference in New Issue
Block a user