mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-06 03:13:48 +02:00
fix: dont fail if there is a .go directory (#1899)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
parent
707639f4d9
commit
40aa04fe71
@ -227,7 +227,7 @@ func checkMain(build config.Build) error {
|
||||
return ferr
|
||||
}
|
||||
if stat.IsDir() {
|
||||
packs, err := parser.ParseDir(token.NewFileSet(), main, nil, 0)
|
||||
packs, err := parser.ParseDir(token.NewFileSet(), main, fileFilter, 0)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse dir: %s: %w", main, err)
|
||||
}
|
||||
@ -250,6 +250,10 @@ func checkMain(build config.Build) error {
|
||||
return fmt.Errorf("build for %s does not contain a main function", build.Binary)
|
||||
}
|
||||
|
||||
func fileFilter(info os.FileInfo) bool {
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
func hasMain(file *ast.File) bool {
|
||||
for _, decl := range file.Decls {
|
||||
fn, isFn := decl.(*ast.FuncDecl)
|
||||
|
@ -342,6 +342,33 @@ func TestBuildCodeInSubdir(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestBuildWithDotGoDir(t *testing.T) {
|
||||
folder, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
require.NoError(t, os.Mkdir(filepath.Join(folder, ".go"), 0755))
|
||||
writeGoodMain(t, folder)
|
||||
var config = config.Project{
|
||||
Builds: []config.Build{
|
||||
{
|
||||
ID: "foo",
|
||||
Env: []string{"GO111MODULE=off"},
|
||||
Binary: "foo",
|
||||
Targets: []string{runtimeTarget},
|
||||
GoBinary: "go",
|
||||
},
|
||||
},
|
||||
}
|
||||
var ctx = context.New(config)
|
||||
ctx.Git.CurrentTag = "5.6.7"
|
||||
var build = ctx.Config.Builds[0]
|
||||
require.NoError(t, Default.Build(ctx, build, api.Options{
|
||||
Target: runtimeTarget,
|
||||
Name: build.Binary,
|
||||
Path: filepath.Join(folder, "dist", runtimeTarget, build.Binary),
|
||||
Ext: "",
|
||||
}))
|
||||
}
|
||||
|
||||
func TestBuildFailed(t *testing.T) {
|
||||
folder, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
|
Loading…
Reference in New Issue
Block a user