Skip to content

Commit

Permalink
refactor: improve tmpl mergeability with pro
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
  • Loading branch information
caarlos0 committed Mar 20, 2023
1 parent f62a2e4 commit 88f3aea
Showing 1 changed file with 36 additions and 31 deletions.
67 changes: 36 additions & 31 deletions internal/tmpl/tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,43 @@ func New(ctx *context.Context) *Template {
sv := ctx.Semver
rawVersionV := fmt.Sprintf("%d.%d.%d", sv.Major, sv.Minor, sv.Patch)

fields := map[string]interface{}{}
for k, v := range map[string]interface{}{
projectName: ctx.Config.ProjectName,
modulePath: ctx.ModulePath,
version: ctx.Version,
rawVersion: rawVersionV,
summary: ctx.Git.Summary,
tag: ctx.Git.CurrentTag,
previousTag: ctx.Git.PreviousTag,
branch: ctx.Git.Branch,
commit: ctx.Git.Commit,
shortCommit: ctx.Git.ShortCommit,
fullCommit: ctx.Git.FullCommit,
commitDate: ctx.Git.CommitDate.UTC().Format(time.RFC3339),
commitTimestamp: ctx.Git.CommitDate.UTC().Unix(),
gitURL: ctx.Git.URL,
env: ctx.Env,
date: ctx.Date.UTC().Format(time.RFC3339),
timestamp: ctx.Date.UTC().Unix(),
now: ctx.Date.UTC(),
major: ctx.Semver.Major,
minor: ctx.Semver.Minor,
patch: ctx.Semver.Patch,
prerelease: ctx.Semver.Prerelease,
isSnapshot: ctx.Snapshot,
releaseNotes: ctx.ReleaseNotes,
releaseURL: ctx.ReleaseURL,
tagSubject: ctx.Git.TagSubject,
tagContents: ctx.Git.TagContents,
tagBody: ctx.Git.TagBody,
runtimeK: ctx.Runtime,
} {
fields[k] = v
}

return &Template{
fields: Fields{
projectName: ctx.Config.ProjectName,
modulePath: ctx.ModulePath,
version: ctx.Version,
rawVersion: rawVersionV,
tag: ctx.Git.CurrentTag,
previousTag: ctx.Git.PreviousTag,
branch: ctx.Git.Branch,
commit: ctx.Git.Commit,
shortCommit: ctx.Git.ShortCommit,
fullCommit: ctx.Git.FullCommit,
commitDate: ctx.Git.CommitDate.UTC().Format(time.RFC3339),
commitTimestamp: ctx.Git.CommitDate.UTC().Unix(),
gitURL: ctx.Git.URL,
summary: ctx.Git.Summary,
tagSubject: ctx.Git.TagSubject,
tagContents: ctx.Git.TagContents,
tagBody: ctx.Git.TagBody,
releaseURL: ctx.ReleaseURL,
env: ctx.Env,
date: ctx.Date.UTC().Format(time.RFC3339),
now: ctx.Date.UTC(),
timestamp: ctx.Date.UTC().Unix(),
major: ctx.Semver.Major,
minor: ctx.Semver.Minor,
patch: ctx.Semver.Patch,
prerelease: ctx.Semver.Prerelease,
isSnapshot: ctx.Snapshot,
releaseNotes: ctx.ReleaseNotes,
runtimeK: ctx.Runtime,
},
fields: fields,
}
}

Expand Down

0 comments on commit 88f3aea

Please sign in to comment.