You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	Default for binary_name
This commit is contained in:
		| @@ -27,6 +27,9 @@ func (Pipe) Run(ctx *context.Context) (err error) { | |||||||
| 			return errors.New("failed reading repo from Git: " + err.Error()) | 			return errors.New("failed reading repo from Git: " + err.Error()) | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	if ctx.Config.BinaryName == "" { | ||||||
|  | 		ctx.Config.BinaryName = strings.Split(ctx.Config.Repo, "/")[1] | ||||||
|  | 	} | ||||||
| 	if ctx.Config.Build.Main == "" { | 	if ctx.Config.Build.Main == "" { | ||||||
| 		ctx.Config.Build.Main = "main.go" | 		ctx.Config.Build.Main = "main.go" | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ func TestFillBasicData(t *testing.T) { | |||||||
| 	assert.NoError(Pipe{}.Run(ctx)) | 	assert.NoError(Pipe{}.Run(ctx)) | ||||||
|  |  | ||||||
| 	assert.Equal("goreleaser/releaser", config.Repo) | 	assert.Equal("goreleaser/releaser", config.Repo) | ||||||
|  | 	assert.Equal("releaser", config.BinaryName) | ||||||
| 	assert.Equal("main.go", config.Build.Main) | 	assert.Equal("main.go", config.Build.Main) | ||||||
| 	assert.Equal("tar.gz", config.Archive.Format) | 	assert.Equal("tar.gz", config.Archive.Format) | ||||||
| 	assert.Contains(config.Build.Oses, "darwin") | 	assert.Contains(config.Build.Oses, "darwin") | ||||||
|   | |||||||
| @@ -1,23 +0,0 @@ | |||||||
| package valid |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"errors" |  | ||||||
|  |  | ||||||
| 	"github.com/goreleaser/releaser/context" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| // Pipe for brew deployment |  | ||||||
| type Pipe struct{} |  | ||||||
|  |  | ||||||
| // Name of the pipe |  | ||||||
| func (Pipe) Description() string { |  | ||||||
| 	return "Validating configuration..." |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Run the pipe |  | ||||||
| func (Pipe) Run(ctx *context.Context) (err error) { |  | ||||||
| 	if ctx.Config.BinaryName == "" { |  | ||||||
| 		return errors.New("missing binary_name") |  | ||||||
| 	} |  | ||||||
| 	return |  | ||||||
| } |  | ||||||
| @@ -1,28 +0,0 @@ | |||||||
| package valid |  | ||||||
|  |  | ||||||
| import ( |  | ||||||
| 	"testing" |  | ||||||
|  |  | ||||||
| 	"github.com/goreleaser/releaser/config" |  | ||||||
| 	"github.com/goreleaser/releaser/context" |  | ||||||
| 	"github.com/stretchr/testify/assert" |  | ||||||
| ) |  | ||||||
|  |  | ||||||
| func runPipe(repo, bin string) error { |  | ||||||
| 	var config = &config.ProjectConfig{ |  | ||||||
| 		Repo:       repo, |  | ||||||
| 		BinaryName: bin, |  | ||||||
| 	} |  | ||||||
| 	var ctx = &context.Context{ |  | ||||||
| 		Config: config, |  | ||||||
| 	} |  | ||||||
| 	return Pipe{}.Run(ctx) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func TestValidadeMissingBinaryName(t *testing.T) { |  | ||||||
| 	assert.Error(t, runPipe("a/b", "")) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func TestValidadeMinimalConfig(t *testing.T) { |  | ||||||
| 	assert.NoError(t, runPipe("", "a")) |  | ||||||
| } |  | ||||||
		Reference in New Issue
	
	Block a user