Skip to content

Commit

Permalink
Merge 3fa38b9 into 6050f20
Browse files Browse the repository at this point in the history
  • Loading branch information
frimik committed Mar 8, 2020
2 parents 6050f20 + 3fa38b9 commit 6a27a17
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions chglog.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Options struct {
RevertPattern string // A regular expression to use for parsing the revert commit
RevertPatternMaps []string // Similar to `HeaderPatternMaps`
NoteKeywords []string // Keyword list to find `Note`. A semicolon is a separator, like `<keyword>:` (e.g. `BREAKING CHANGE`)
Paths []string // Path filter
}

// Info is metadata related to CHANGELOG
Expand Down
1 change: 1 addition & 0 deletions cmd/git-chglog/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (config *Config) Convert(ctx *CLIContext) *chglog.Config {
Options: &chglog.Options{
NextTag: ctx.NextTag,
TagFilterPattern: ctx.TagFilterPattern,
Paths: ctx.Paths,
CommitFilters: opts.Commits.Filters,
CommitSortBy: opts.Commits.SortBy,
CommitGroupBy: opts.CommitGroups.GroupBy,
Expand Down
1 change: 1 addition & 0 deletions cmd/git-chglog/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type CLIContext struct {
Query string
NextTag string
TagFilterPattern string
Paths []string
}

// InitContext ...
Expand Down
12 changes: 10 additions & 2 deletions cmd/git-chglog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App {
Usage: "generate the git-chglog configuration file in interactive",
},

// path
cli.StringSliceFlag{
Name: "path",
Usage: "Paths to include in changelog",
},

// config
cli.StringFlag{
Name: "config, c",
Expand Down Expand Up @@ -116,8 +122,8 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App {

// tag-filter-pattern
cli.StringFlag{
Name: "tag-filter-pattern, p",
Usage: "Regular expression of tag filter. Is specified, only matched tags will be picked",
Name: "tag-filter-pattern, p",
Usage: "Regular expression of tag filter. Is specified, only matched tags will be picked",
},

// help & version
Expand Down Expand Up @@ -172,7 +178,9 @@ func AppAction(c *cli.Context) error {
NoEmoji: c.Bool("no-emoji"),
Query: c.Args().First(),
NextTag: c.String("next-tag"),

TagFilterPattern: c.String("tag-filter-pattern"),
Paths: c.StringSlice("path"),
},
fs,
NewConfigLoader(),
Expand Down
16 changes: 12 additions & 4 deletions commit_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ func newCommitParser(client gitcmd.Client, config *Config) *commitParser {
}

func (p *commitParser) Parse(rev string) ([]*Commit, error) {
out, err := p.client.Exec(
"log",
paths := p.config.Options.Paths

args := []string{
rev,
"--no-decorate",
"--pretty="+logFormat,
)
"--pretty=" + logFormat,
}

if len(paths) > 0 {
args = append(args, "--")
args = append(args, paths...)
}

out, err := p.client.Exec("log", args...)

if err != nil {
return nil, err
Expand Down

0 comments on commit 6a27a17

Please sign in to comment.