fix: correct time layout (#13)

* fix: use correct date layout

* chore: wrap date layout inside parenthesis

Co-authored-by: Tran Hau <ngtranhau@gmail.com>
main
sudo pacman -Syu 2021-04-15 11:59:01 +07:00 committed by GitHub
parent 640d18c79d
commit 7d04c80d6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 18 additions and 18 deletions

1
go.mod
View File

@ -7,6 +7,7 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/go-git/go-git/v5 v5.3.0
github.com/google/go-cmp v0.5.5 // indirect
github.com/haunt98/clock v0.1.0
github.com/haunt98/color v0.1.0
github.com/kevinburke/ssh_config v1.1.0 // indirect
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e

2
go.sum
View File

@ -35,6 +35,8 @@ github.com/go-git/go-git/v5 v5.3.0/go.mod h1:xdX4bWJ48aOrdhnl2XqHYstHbbp6+LFS4r4
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/haunt98/clock v0.1.0 h1:iRaGSoQ21Z+gD9J4mVoYqL4liAg5eGwPkkPGknmfV6A=
github.com/haunt98/clock v0.1.0/go.mod h1:Sq2/R7IgMjxnqgCF3f69ROb8ZeF9PO0YaQW1p3wXGiE=
github.com/haunt98/color v0.1.0 h1:qfP5oNI3aoUC8T+bH/JNVAg79ljyhTGpgfqSKWhkiQQ=
github.com/haunt98/color v0.1.0/go.mod h1:V4BPVUSuiOItuVZHRHUTkpxO7OYQiP0DSgIWMpC/2qs=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=

View File

@ -7,6 +7,7 @@ import (
"github.com/haunt98/changeloguru/pkg/convention"
"github.com/haunt98/changeloguru/pkg/markdown"
"github.com/haunt98/clock"
)
const (
@ -70,9 +71,10 @@ func GenerateMarkdown(commits []convention.Commit, scopes map[string]struct{}, v
}
// Adding title, version to nodes
versionHeader := fmt.Sprintf("%s (%s)", version, clock.FormatDate(when))
nodes = append([]markdown.Node{
markdown.NewHeader(firstLevel, title),
markdown.NewHeader(secondLevel, getVersionHeader(version, when)),
markdown.NewHeader(secondLevel, versionHeader),
}, nodes...)
return nodes
@ -89,8 +91,3 @@ func ParseMarkdown(data string) []markdown.Node {
return nodes
}
func getVersionHeader(version string, when time.Time) string {
year, month, day := when.Date()
return fmt.Sprintf("%s (%d-%d-%d)", version, year, month, day)
}

View File

@ -1,6 +1,6 @@
# CHANGELOG
## v1.0.0 (2020-1-18)
## v1.0.0 (2020-01-18)
### Added

View File

@ -1,6 +1,6 @@
# CHANGELOG
## v1.0.0 (2020-3-22)
## v1.0.0 (2020-03-22)
### Added

View File

@ -1,6 +1,6 @@
# CHANGELOG
## v1.0.0 (2020-1-18)
## v1.0.0 (2020-01-18)
### Added

View File

@ -7,6 +7,7 @@ import (
"strings"
"github.com/haunt98/changeloguru/pkg/git"
"github.com/haunt98/clock"
)
var (
@ -51,8 +52,7 @@ func GetTypeAndScope(gitCommit git.Commit) OptionFn {
func AddAuthorDate(gitCommit git.Commit) OptionFn {
return func(c *Commit) error {
year, month, day := gitCommit.Author.When.Date()
c.RawHeader = fmt.Sprintf("%s (%d-%d-%d)", c.RawHeader, year, month, day)
c.RawHeader = fmt.Sprintf("%s (%s)", c.RawHeader, clock.FormatDate(gitCommit.Author.When))
return nil
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "docs: correct spelling of CHANGELOG (1-1-1)",
"RawHeader": "docs: correct spelling of CHANGELOG (0001-01-01)",
"Type": "docs",
"Scope": ""
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "refactor!: drop support for Node 6 (1-1-1)",
"RawHeader": "refactor!: drop support for Node 6 (0001-01-01)",
"Type": "refactor",
"Scope": ""
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "feat(lang): add polish language (1-1-1)",
"RawHeader": "feat(lang): add polish language (0001-01-01)",
"Type": "feat",
"Scope": "lang"
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "random git message (1-1-1)",
"RawHeader": "random git message (0001-01-01)",
"Type": "misc",
"Scope": ""
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "random git message (2020-4-1)",
"RawHeader": "random git message (2020-04-01)",
"Type": "misc",
"Scope": ""
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "Docs: correct spelling of CHANGELOG (1-1-1)",
"RawHeader": "Docs: correct spelling of CHANGELOG (0001-01-01)",
"Type": "docs",
"Scope": ""
}

View File

@ -1,5 +1,5 @@
{
"RawHeader": "REFACTOR!: drop support for Node 6 (1-1-1)",
"RawHeader": "REFACTOR!: drop support for Node 6 (0001-01-01)",
"Type": "refactor",
"Scope": ""
}