1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

fix: infer project name from GitLab/Gitea release (#1364)

This commit is contained in:
Craig Furman 2020-02-26 12:38:07 +00:00 committed by GitHub
parent d03c0aa0be
commit 61fb8f50cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 3 deletions

View File

@ -13,7 +13,14 @@ func (Pipe) String() string {
// Default set project defaults
func (Pipe) Default(ctx *context.Context) error {
if ctx.Config.ProjectName == "" {
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
switch {
case ctx.Config.Release.GitHub.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.GitHub.Name
case ctx.Config.Release.GitLab.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.GitLab.Name
case ctx.Config.Release.Gitea.Name != "":
ctx.Config.ProjectName = ctx.Config.Release.Gitea.Name
}
}
return nil
}

View File

@ -23,7 +23,7 @@ func TestCustomProjectName(t *testing.T) {
require.Equal(t, "foo", ctx.Config.ProjectName)
}
func TestEmptyProjectName(t *testing.T) {
func TestEmptyProjectName_DefaultsToGitHubRelease(t *testing.T) {
var ctx = context.New(config.Project{
Release: config.Release{
GitHub: config.Repo{
@ -35,3 +35,29 @@ func TestEmptyProjectName(t *testing.T) {
require.NoError(t, Pipe{}.Default(ctx))
require.Equal(t, "bar", ctx.Config.ProjectName)
}
func TestEmptyProjectName_DefaultsToGitLabRelease(t *testing.T) {
var ctx = context.New(config.Project{
Release: config.Release{
GitLab: config.Repo{
Owner: "bar",
Name: "bar",
},
},
})
require.NoError(t, Pipe{}.Default(ctx))
require.Equal(t, "bar", ctx.Config.ProjectName)
}
func TestEmptyProjectName_DefaultsToGiteaRelease(t *testing.T) {
var ctx = context.New(config.Project{
Release: config.Release{
Gitea: config.Repo{
Owner: "bar",
Name: "bar",
},
},
})
require.NoError(t, Pipe{}.Default(ctx))
require.Equal(t, "bar", ctx.Config.ProjectName)
}

View File

@ -6,7 +6,8 @@ weight: 10
---
The project name is used in the name of the Brew formula, archives, etc.
If none is given, it will be inferred from the name of the Git project.
If none is given, it will be inferred from the name of the GitHub, GitLab, or
Gitea release.
```yaml
# .goreleaser.yml