Skip to content

Commit

Permalink
[fix] Initial error
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamontat Chantrachirathumrong committed Sep 12, 2018
1 parent 19afa5d commit d6c9909
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 6 deletions.
49 changes: 49 additions & 0 deletions .gitgo/chglog/CHANGELOG.tpl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
32 changes: 32 additions & 0 deletions .gitgo/chglog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/kamontat/gitgo
options:
commits:
filters:
Type:
- feature
- fix
- improve
- refactor
- doc
commit_groups:
title_maps:
feature: Features
improve: Improving User Experience
refactor: Code Refactoring
fix: Fixes Bug
doc: Documentation
header:
pattern: "^\\[(\\w*)\\]\\s(.*)$"
pattern_maps:
- Type
- Subject
issues:
prefix:
- "#"
notes:
keywords:
- BREAKING CHANGE
13 changes: 9 additions & 4 deletions cmd/changelogInitial.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ var changelogInitialCmd = &cobra.Command{

yaml := model.GeneratorYAML()

conf := Open(gitgoStr, "config.yml")
tmp := Open(gitgoStr, "CHANGELOG.tpl.md")
conf := openFile(gitgoStr, "config.yml")
tmp := openFile(gitgoStr, "CHANGELOG.tpl.md")

var style string
survey.AskOne(&survey.Select{
Expand All @@ -77,8 +77,13 @@ func getChgLogConfig(parent, file string) string {
return path.Join(parent, "chglog", file)
}

func Open(parent, file string) *os.File {
f, err := os.OpenFile(getChgLogConfig(parent, file), os.O_CREATE|os.O_WRONLY, os.ModePerm)
func openFile(parent, file string) *os.File {
filepath := getChgLogConfig(parent, file)
d := path.Dir(filepath)
os.MkdirAll(d, os.ModePerm)

f, err := os.OpenFile(filepath, os.O_CREATE|os.O_WRONLY, os.ModePerm)

e.ShowAndExit(e.ThrowE(e.InitialError, err))
return f
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
package cmd

import (
"github.com/skratchdot/open-golang/open"

"github.com/kamontat/go-log-manager"
"github.com/skratchdot/open-golang/open"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down

0 comments on commit d6c9909

Please sign in to comment.