mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
fix(changelog): first release default to git changelogger (#5242)
the `/compare` api doesn't allow to omit the previous reference, nor to use a git commit, so, if `previous tag` is empty, we're now defaulting to the git changelog implementation, which should resolve the problem. closes #5240 --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
973dde6879
commit
9a68c54d53
@ -344,6 +344,10 @@ func getChangeloger(ctx *context.Context) (changeloger, error) {
|
||||
case useGit, "":
|
||||
return gitChangeloger{}, nil
|
||||
case useGitLab, useGitea, useGitHub:
|
||||
if ctx.Git.PreviousTag == "" {
|
||||
log.Warnf("there's no previous tag, using 'git' instead of '%s'", ctx.Config.Changelog.Use)
|
||||
return gitChangeloger{}, nil
|
||||
}
|
||||
return newSCMChangeloger(ctx)
|
||||
case useGitHubNative:
|
||||
return newGithubChangeloger(ctx)
|
||||
|
@ -645,18 +645,29 @@ func TestGetChangeloger(t *testing.T) {
|
||||
Changelog: config.Changelog{
|
||||
Use: useGitHub,
|
||||
},
|
||||
}, testctx.GitHubTokenType)
|
||||
}, testctx.GitHubTokenType, testctx.WithPreviousTag("v1.2.3"))
|
||||
c, err := getChangeloger(ctx)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, &scmChangeloger{}, c)
|
||||
})
|
||||
|
||||
t.Run(useGitHub+" no previous", func(t *testing.T) {
|
||||
ctx := testctx.NewWithCfg(config.Project{
|
||||
Changelog: config.Changelog{
|
||||
Use: useGitHub,
|
||||
},
|
||||
}, testctx.GitHubTokenType)
|
||||
c, err := getChangeloger(ctx)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, gitChangeloger{}, c)
|
||||
})
|
||||
|
||||
t.Run(useGitHubNative, func(t *testing.T) {
|
||||
ctx := testctx.NewWithCfg(config.Project{
|
||||
Changelog: config.Changelog{
|
||||
Use: useGitHubNative,
|
||||
},
|
||||
}, testctx.GitHubTokenType)
|
||||
}, testctx.GitHubTokenType, testctx.WithPreviousTag("v1.2.3"))
|
||||
c, err := getChangeloger(ctx)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, &githubNativeChangeloger{}, c)
|
||||
@ -681,7 +692,7 @@ func TestGetChangeloger(t *testing.T) {
|
||||
Changelog: config.Changelog{
|
||||
Use: useGitLab,
|
||||
},
|
||||
}, testctx.GitLabTokenType)
|
||||
}, testctx.GitLabTokenType, testctx.WithPreviousTag("v1.2.3"))
|
||||
c, err := getChangeloger(ctx)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, &scmChangeloger{}, c)
|
||||
@ -695,7 +706,7 @@ func TestGetChangeloger(t *testing.T) {
|
||||
Changelog: config.Changelog{
|
||||
Use: useGitHub,
|
||||
},
|
||||
}, testctx.GitHubTokenType)
|
||||
}, testctx.GitHubTokenType, testctx.WithPreviousTag("v1.2.3"))
|
||||
c, err := getChangeloger(ctx)
|
||||
require.EqualError(t, err, "unsupported repository URL: https://gist.github.com/")
|
||||
require.Nil(t, c)
|
||||
@ -717,7 +728,7 @@ func TestGetChangeloger(t *testing.T) {
|
||||
GiteaURLs: config.GiteaURLs{
|
||||
API: srv.URL,
|
||||
},
|
||||
}, testctx.GiteaTokenType)
|
||||
}, testctx.GiteaTokenType, testctx.WithPreviousTag("v1.2.3"))
|
||||
c, err := getChangeloger(ctx)
|
||||
require.NoError(t, err)
|
||||
require.IsType(t, &scmChangeloger{}, c)
|
||||
|
Loading…
x
Reference in New Issue
Block a user