Skip to content

Commit

Permalink
feat(BREAKING): remove stringsJoin method in template renderer and make
Browse files Browse the repository at this point in the history
                Closes to string

BREAKING CHANGE:

before:

```
Closes: {{ stringsJoin .Field.Footer.Closes "," }}
```

after:

```
Closes: {{ .Field.Footer.Closes }}
```
  • Loading branch information
axetroy committed Oct 3, 2021
1 parent 8c96222 commit cf4cb17
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion 4_generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func Generate(g *client.GitClient, contexts []*transformer.TemplateContext, form
t := template.New(ctx.Version)

t.Funcs(template.FuncMap{
"stringsJoin": strings.Join,
"unescape": func(s string) template.HTML {
return template.HTML(s)
},
Expand Down
2 changes: 1 addition & 1 deletion 4_generator/template/default.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{- define "body" -}}
{{range . -}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ .Field.Footer.Closes }} {{- end }} {{- end}}
{{ end }}
{{- end -}}

Expand Down
2 changes: 1 addition & 1 deletion 4_generator/template/full.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{- define "body" -}}
{{range . -}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ .Field.Footer.Closes }} {{- end }} {{- end}}
{{ end }}
{{- end -}}

Expand Down
2 changes: 1 addition & 1 deletion 4_generator/template/simple.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{- define "body" -}}
{{range . -}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) {{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) {{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ .Field.Footer.Closes }} {{- end }} {{- end}}
{{ end }}
{{- end -}}

Expand Down
3 changes: 1 addition & 2 deletions CUSTOM_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ There are 3 parts in Context

1. **unescape(text string)**: unescape the string
2. **hashURL(commitHashString string)**: Add URL to commit
3. **stringsJoin(arr []string)**: Join string

source code:

Expand Down Expand Up @@ -79,7 +78,7 @@ type BreakingChange struct {

type Footer struct {
BreakingChange *BreakingChange
Closes []string
Closes string
}


Expand Down
4 changes: 2 additions & 2 deletions internal/commit/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type BreakingChange struct {

type Footer struct {
BreakingChange *BreakingChange
Closes []string
Closes string
}

/*
Expand Down Expand Up @@ -126,7 +126,7 @@ func Parser(message string) *Message {
for i, issue := range issues {
issues[i] = strings.TrimRight(strings.TrimSpace(issue), ".")
}
m.Footer.Closes = issues
m.Footer.Closes = strings.Join(issues, ", ")
continue
} else if len(breakingChangeFooterMatchers) != 0 {
isBreakingChangeBlock = true
Expand Down
2 changes: 1 addition & 1 deletion release.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- define "body" -}}
{{range . -}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{ hashURL .Hash}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ .Field.Footer.Closes }} {{- end }} {{- end}}
{{ end }}
{{- end -}}

Expand Down

0 comments on commit cf4cb17

Please sign in to comment.