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:
parent
d03c0aa0be
commit
61fb8f50cc
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user