1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-18 03:56:52 +02:00

fix: getting previous tag

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos A Becker 2022-10-17 22:39:32 -03:00
parent 27cbbd8e66
commit f90df0f5ec
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 7 additions and 5 deletions

View File

@ -205,11 +205,11 @@ func getCommitDate(ctx *context.Context) (time.Time, error) {
}
func getShortCommit(ctx *context.Context) (string, error) {
return git.Clean(git.Run(ctx, "show", "--format='%h'", "HEAD", "--quiet"))
return git.Clean(git.Run(ctx, "show", "--format=%h", "HEAD", "--quiet"))
}
func getFullCommit(ctx *context.Context) (string, error) {
return git.Clean(git.Run(ctx, "show", "--format='%H'", "HEAD", "--quiet"))
return git.Clean(git.Run(ctx, "show", "--format=%H", "HEAD", "--quiet"))
}
func getSummary(ctx *context.Context) (string, error) {
@ -294,7 +294,7 @@ func previousTagSha(ctx *context.Context, current string) (string, error) {
if err != nil {
return "", err
}
return git.Clean(git.Run(ctx, "show", "--format='%h'", tag, "--quiet"))
return git.Clean(git.Run(ctx, "rev-list", "-n1", tag))
}
func getURL(ctx *context.Context) (string, error) {

View File

@ -192,11 +192,13 @@ func TestValidState(t *testing.T) {
testlib.GitRemoteAdd(t, "git@github.com:foo/bar.git")
testlib.GitCommit(t, "commit3")
testlib.GitTag(t, "v0.0.1")
testlib.GitCommit(t, "commit4")
testlib.GitTag(t, "v0.0.2")
testlib.GitCommit(t, "commit4")
testlib.GitTag(t, "v0.0.3")
ctx := context.New(config.Project{})
require.NoError(t, Pipe{}.Run(ctx))
require.Equal(t, "v0.0.2", ctx.Git.CurrentTag)
require.Equal(t, "v0.0.2", ctx.Git.PreviousTag)
require.Equal(t, "v0.0.3", ctx.Git.CurrentTag)
require.Equal(t, "git@github.com:foo/bar.git", ctx.Git.URL)
}