mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
feat: Add config normalize process
This commit is contained in:
parent
d4d2a7ed80
commit
633c7f0e89
1 changed files with 29 additions and 0 deletions
29
chglog.go
29
chglog.go
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue