feat: Add config normalize process

This commit is contained in:
tsuyoshiwada 2018-02-17 01:37:20 +09:00
parent d4d2a7ed80
commit 633c7f0e89

View file

@ -50,6 +50,33 @@ type Config struct {
Options *Options
}
func normalizeConfig(config *Config) {
opts := config.Options
if opts.HeaderPattern == "" {
opts.HeaderPattern = "^(.*)$"
opts.HeaderPatternMaps = []string{
"Subject",
}
}
if opts.MergePattern == "" {
opts.MergePattern = "^Merge branch '(\\w+)'$"
opts.MergePatternMaps = []string{
"Source",
}
}
if opts.RevertPattern == "" {
opts.RevertPattern = "^Revert \"([\\s\\S]*)\"$"
opts.RevertPatternMaps = []string{
"Header",
}
}
config.Options = opts
}
// Generator ...
type Generator struct {
client gitcmd.Client
@ -70,6 +97,8 @@ func NewGenerator(config *Config) *Generator {
config.Options.Processor.Bootstrap(config)
}
normalizeConfig(config)
return &Generator{
client: client,
config: config,