1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-11-06 09:09:29 +02:00

feat: add support for git branch in templates (#1906)

Add a `.Branch` field to the text templates populated by the current git
branch.

Signed-off-by: Ben Kochie <superq@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Ben Kochie
2020-11-18 19:50:31 +01:00
committed by GitHub
parent fa9bb22124
commit f417d7783d
6 changed files with 32 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ const (
version = "Version"
rawVersion = "RawVersion"
tag = "Tag"
branch = "Branch"
commit = "Commit"
shortCommit = "ShortCommit"
fullCommit = "FullCommit"
@@ -74,6 +75,7 @@ func New(ctx *context.Context) *Template {
version: ctx.Version,
rawVersion: rawVersionV,
tag: ctx.Git.CurrentTag,
branch: ctx.Git.Branch,
commit: ctx.Git.Commit,
shortCommit: ctx.Git.ShortCommit,
fullCommit: ctx.Git.FullCommit,

View File

@@ -26,6 +26,7 @@ func TestWithArtifact(t *testing.T) {
Minor: 2,
Patch: 3,
}
ctx.Git.Branch = "test-branch"
ctx.Git.Commit = "commit"
ctx.Git.FullCommit = "fullcommit"
ctx.Git.ShortCommit = "shortcommit"
@@ -38,6 +39,7 @@ func TestWithArtifact(t *testing.T) {
"1.2.3": "{{.Version}}",
"v1.2.3": "{{.Tag}}",
"1-2-3": "{{.Major}}-{{.Minor}}-{{.Patch}}",
"test-branch": "{{.Branch}}",
"commit": "{{.Commit}}",
"fullcommit": "{{.FullCommit}}",
"shortcommit": "{{.ShortCommit}}",