mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
* Argument: --path filtering - refs #35 * Minor documentation additions for Paths option
This commit is contained in:
parent
a1c84d7a0d
commit
9d62af2943
6 changed files with 28 additions and 5 deletions
|
|
@ -182,6 +182,7 @@ USAGE:
|
|||
|
||||
OPTIONS:
|
||||
--init generate the git-chglog configuration file in interactive
|
||||
--path value Filter commits by path(s). Can use multiple times.
|
||||
--config value, -c value specifies a different configuration file to pick up (default: ".chglog/config.yml")
|
||||
--output value, -o value output path and filename for the changelogs. If not specified, output to stdout
|
||||
--next-tag value treat unreleased commits as specified tags (EXPERIMENTAL)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ type Options struct {
|
|||
JiraUrl string
|
||||
JiraTypeMaps map[string]string
|
||||
JiraIssueDescriptionPattern string
|
||||
Paths []string // Path filter
|
||||
}
|
||||
|
||||
// Info is metadata related to CHANGELOG
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ func (config *Config) Convert(ctx *CLIContext) *chglog.Config {
|
|||
NextTag: ctx.NextTag,
|
||||
TagFilterPattern: ctx.TagFilterPattern,
|
||||
NoCaseSensitive: ctx.NoCaseSensitive,
|
||||
Paths: ctx.Paths,
|
||||
CommitFilters: opts.Commits.Filters,
|
||||
CommitSortBy: opts.Commits.SortBy,
|
||||
CommitGroupBy: opts.CommitGroups.GroupBy,
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ type CLIContext struct {
|
|||
JiraUsername string
|
||||
JiraToken string
|
||||
JiraUrl string
|
||||
Paths []string
|
||||
}
|
||||
|
||||
// InitContext ...
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App {
|
|||
|
||||
$ {{.Name}} --config custom/dir/config.yml
|
||||
|
||||
The above is a command that uses a configuration file placed other than ".chglog/config.yml".
|
||||
The above is a command that uses a configuration file placed other than ".chglog/config.yml".
|
||||
|
||||
$ {{.Name}} --path path/to/my/component --output CHANGELOG.component.md
|
||||
|
||||
Filter commits by specific paths or files in git and output to a component specific changelog.
|
||||
`,
|
||||
ttl("USAGE:"),
|
||||
ttl("OPTIONS:"),
|
||||
|
|
@ -76,6 +80,12 @@ func CreateApp(actionFunc cli.ActionFunc) *cli.App {
|
|||
Usage: "generate the git-chglog configuration file in interactive",
|
||||
},
|
||||
|
||||
// path
|
||||
&cli.StringSliceFlag{
|
||||
Name: "path",
|
||||
Usage: "Filter commits by path(s). Can use multiple times.",
|
||||
},
|
||||
|
||||
// config
|
||||
&cli.StringFlag{
|
||||
Name: "config, c",
|
||||
|
|
@ -216,6 +226,7 @@ func AppAction(c *cli.Context) error {
|
|||
JiraUsername: c.String("jira-username"),
|
||||
JiraToken: c.String("jira-token"),
|
||||
JiraUrl: c.String("jira-url"),
|
||||
Paths: c.StringSlice("path"),
|
||||
},
|
||||
fs,
|
||||
NewConfigLoader(),
|
||||
|
|
|
|||
|
|
@ -86,12 +86,20 @@ func newCommitParser(logger *Logger, client gitcmd.Client, jiraClient JiraClient
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue