You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	fix: fail if cant guess project name (#1378)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							9ba04398a2
						
					
				
				
					commit
					5efb690d1c
				
			| @@ -1,7 +1,11 @@ | ||||
| // Package project sets "high level" defaults related to the project. | ||||
| package project | ||||
|  | ||||
| import "github.com/goreleaser/goreleaser/pkg/context" | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/goreleaser/goreleaser/pkg/context" | ||||
| ) | ||||
|  | ||||
| // Pipe implemens defaulter to set the project name | ||||
| type Pipe struct{} | ||||
| @@ -20,6 +24,8 @@ func (Pipe) Default(ctx *context.Context) error { | ||||
| 			ctx.Config.ProjectName = ctx.Config.Release.GitLab.Name | ||||
| 		case ctx.Config.Release.Gitea.Name != "": | ||||
| 			ctx.Config.ProjectName = ctx.Config.Release.Gitea.Name | ||||
| 		default: | ||||
| 			return fmt.Errorf("couldn't guess project_name, please add it to your config") | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
|   | ||||
| @@ -61,3 +61,12 @@ func TestEmptyProjectName_DefaultsToGiteaRelease(t *testing.T) { | ||||
| 	require.NoError(t, Pipe{}.Default(ctx)) | ||||
| 	require.Equal(t, "bar", ctx.Config.ProjectName) | ||||
| } | ||||
|  | ||||
| func TestEmptyProjectNameAndRelease(t *testing.T) { | ||||
| 	var ctx = context.New(config.Project{ | ||||
| 		Release: config.Release{ | ||||
| 			GitHub: config.Repo{}, | ||||
| 		}, | ||||
| 	}) | ||||
| 	require.EqualError(t, Pipe{}.Default(ctx), "couldn't guess project_name, please add it to your config") | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user