mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
parent
0ae5e13a06
commit
75d59a9eb8
3 changed files with 42 additions and 8 deletions
|
|
@ -224,6 +224,8 @@ info:
|
|||
repository_url: https://github.com/git-chglog/git-chglog
|
||||
|
||||
options:
|
||||
tag_filter_pattern: '^v'
|
||||
|
||||
commits:
|
||||
filters:
|
||||
Type:
|
||||
|
|
|
|||
|
|
@ -50,14 +50,15 @@ type NoteOptions struct {
|
|||
|
||||
// Options ...
|
||||
type Options struct {
|
||||
Commits CommitOptions `yaml:"commits"`
|
||||
CommitGroups CommitGroupOptions `yaml:"commit_groups"`
|
||||
Header PatternOptions `yaml:"header"`
|
||||
Issues IssueOptions `yaml:"issues"`
|
||||
Refs RefOptions `yaml:"refs"`
|
||||
Merges PatternOptions `yaml:"merges"`
|
||||
Reverts PatternOptions `yaml:"reverts"`
|
||||
Notes NoteOptions `yaml:"notes"`
|
||||
TagFilterPattern string `yaml:"tag_filter_pattern"`
|
||||
Commits CommitOptions `yaml:"commits"`
|
||||
CommitGroups CommitGroupOptions `yaml:"commit_groups"`
|
||||
Header PatternOptions `yaml:"header"`
|
||||
Issues IssueOptions `yaml:"issues"`
|
||||
Refs RefOptions `yaml:"refs"`
|
||||
Merges PatternOptions `yaml:"merges"`
|
||||
Reverts PatternOptions `yaml:"reverts"`
|
||||
Notes NoteOptions `yaml:"notes"`
|
||||
}
|
||||
|
||||
// Config ...
|
||||
|
|
@ -248,6 +249,10 @@ func (config *Config) Convert(ctx *CLIContext) *chglog.Config {
|
|||
info := config.Info
|
||||
opts := config.Options
|
||||
|
||||
if ctx.TagFilterPattern == "" {
|
||||
ctx.TagFilterPattern = opts.TagFilterPattern
|
||||
}
|
||||
|
||||
return &chglog.Config{
|
||||
Bin: config.Bin,
|
||||
WorkingDir: ctx.WorkingDir,
|
||||
|
|
|
|||
|
|
@ -41,3 +41,30 @@ func TestConfigNormalize(t *testing.T) {
|
|||
assert.Nil(err)
|
||||
assert.Equal(filepath.Join(cwd, "CHANGELOG.tpl.md"), config.Template)
|
||||
}
|
||||
|
||||
func TestConfigConvert(t *testing.T) {
|
||||
var patternInFile = "pattern in config"
|
||||
var patternInArgs = "pattern in cli"
|
||||
assert := assert.New(t)
|
||||
// basic
|
||||
config := &Config{
|
||||
Info: Info{
|
||||
RepositoryURL: "https://example.com/foo/bar/",
|
||||
},
|
||||
Options: Options{TagFilterPattern: patternInFile},
|
||||
}
|
||||
cli := &CLIContext{TagFilterPattern: patternInArgs}
|
||||
cfg := config.Convert(cli)
|
||||
assert.Equal(cfg.Options.TagFilterPattern, patternInArgs)
|
||||
|
||||
config = &Config{
|
||||
Info: Info{
|
||||
RepositoryURL: "https://example.com/foo/bar/",
|
||||
},
|
||||
Options: Options{TagFilterPattern: patternInFile},
|
||||
}
|
||||
cli = &CLIContext{}
|
||||
cfg = config.Convert(cli)
|
||||
assert.Equal(cfg.Options.TagFilterPattern, patternInFile)
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue