Skip to content

Commit

Permalink
feat: add full preset template
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Nov 23, 2020
1 parent 7068672 commit 7553570
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 453 deletions.
2 changes: 2 additions & 0 deletions 4_generator/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func Generate(g *client.GitClient, contexts []*transformer.TemplateContext, form
switch preset {
case "default":
templateStr = DEFAULT_TEMPLATE
case "full":
templateStr = FULL_TEMPLATE
default:
return nil, errors.Errorf("invalid preset '%s'", preset)
}
Expand Down
16 changes: 4 additions & 12 deletions 4_generator/template_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,22 @@ const DEFAULT_TEMPLATE = `# {{ .Version }}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{.Short}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
{{ end }}
{{- end -}}
{{if .Feat}}
### New feature:
{{ template "body" .Feat }}
{{- end -}}
{{if .Fix}}
### Bugs fixed:
{{ template "body" .Fix }}
{{- end -}}
{{if .Refactor}}
### Code Refactoring:
{{ template "body" .Refactor }}
{{- end -}}
{{if .Test}}
### Testing:
{{ template "body" .Test }}
{{- end -}}
{{if .Perf}}
### Performance improves:
{{ template "body" .Perf }}
{{- end -}}
{{if .Docs}}
### Documentation:
{{ template "body" .Docs }}
{{- end -}}
{{if .BreakingChanges}}
### BREAKING CHANGES:
{{ range .BreakingChanges -}}
Expand Down
52 changes: 52 additions & 0 deletions 4_generator/template_full.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package generator

const FULL_TEMPLATE = `# {{ .Version }}
{{- define "body" -}}
{{range . -}}
- {{if .Field.Header.Scope }}**{{ unescape .Field.Header.Scope }}**: {{ end }}{{ unescape .Field.Header.Subject }}({{.Short}}) (thanks @{{ unescape .Author.Name }}){{if .Field.Footer }} {{if .Field.Footer.Closes }}, Closes: {{ stringsJoin .Field.Footer.Closes "," }} {{- end }} {{- end}}
{{ end }}
{{- end -}}
{{if .Feat}}
### New feature:
{{ template "body" .Feat }}
{{- end -}}
{{if .Fix}}
### Bugs fixed:
{{ template "body" .Fix }}
{{- end -}}
{{if .Refactor}}
### Code Refactoring:
{{ template "body" .Refactor }}
{{- end -}}
{{if .Test}}
### Testing:
{{ template "body" .Test }}
{{- end -}}
{{if .Perf}}
### Performance improves:
{{ template "body" .Perf }}
{{- end -}}
{{if .Docs}}
### Documentation:
{{ template "body" .Docs }}
{{- end -}}
{{if .BreakingChanges}}
### BREAKING CHANGES:
{{ range .BreakingChanges -}}
- {{if .Field.Footer.BreakingChange.Title}}{{ unescape .Field.Footer.BreakingChange.Title }}{{ else }}{{ unescape .Field.Title }}{{ end }}
{{ unescape .Field.Footer.BreakingChange.Content }}
{{- end -}}
{{- end}}
### Commits({{ len .Commits }}):
{{range .Commits -}}
- **{{ .Short }}** {{ unescape .Field.Title }}
{{ end }}`
Loading

0 comments on commit 7553570

Please sign in to comment.