mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
0eb3e7975c
This reverts back to using `git archive` for the source archives... but will keep supporting extra files. ##### How it works: Basically, we run `git archive` as before. Then, we make a backup of the generated archive, and create a new one copying by reading from the backup and writing into the new one. Finally, we write the extra files to the new one as well. This only happens if the configuration does have extra files, otherwise, just the simple `git archive` will be run. PS: we can't just append to the archive because weird tar format paddings et al. --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
package archive
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/goreleaser/goreleaser/internal/testctx"
|
|
"github.com/goreleaser/goreleaser/internal/testlib"
|
|
"github.com/goreleaser/goreleaser/pkg/config"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestMeta(t *testing.T) {
|
|
t.Run("good", func(t *testing.T) {
|
|
dist := t.TempDir()
|
|
ctx := testctx.NewWithCfg(config.Project{
|
|
Dist: dist,
|
|
Archives: []config.Archive{
|
|
{
|
|
Meta: true,
|
|
NameTemplate: "foo",
|
|
Files: []config.File{
|
|
{Source: "testdata/**/*.txt"},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.NoError(t, Pipe{}.Run(ctx))
|
|
require.Equal(
|
|
t,
|
|
[]string{"testdata/a/a.txt", "testdata/a/b/a.txt", "testdata/a/b/c/d.txt"},
|
|
testlib.LsArchive(t, filepath.Join(dist, "foo.tar.gz"), "tar.gz"),
|
|
)
|
|
})
|
|
|
|
t.Run("bad tmpl", func(t *testing.T) {
|
|
dist := t.TempDir()
|
|
ctx := testctx.NewWithCfg(config.Project{
|
|
Dist: dist,
|
|
Archives: []config.Archive{
|
|
{
|
|
Meta: true,
|
|
NameTemplate: "foo{{.Os}}",
|
|
Files: []config.File{
|
|
{Source: "testdata/**/*.txt"},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.EqualError(t, Pipe{}.Run(ctx), `template: tmpl:1:5: executing "tmpl" at <.Os>: map has no entry for key "Os"`)
|
|
})
|
|
|
|
t.Run("no files", func(t *testing.T) {
|
|
dist := t.TempDir()
|
|
ctx := testctx.NewWithCfg(config.Project{
|
|
Dist: dist,
|
|
Archives: []config.Archive{
|
|
{
|
|
Meta: true,
|
|
NameTemplate: "foo",
|
|
},
|
|
},
|
|
})
|
|
|
|
require.NoError(t, Pipe{}.Default(ctx))
|
|
require.EqualError(t, Pipe{}.Run(ctx), `no files found`)
|
|
})
|
|
}
|