mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
feat: Add --tag-filter-pattern flag.
This flag specifies a regular expression and only matched tags will be included in change log. Closes #43
This commit is contained in:
parent
63a4e63702
commit
1198e283de
10 changed files with 222 additions and 65 deletions
|
|
@ -2,6 +2,7 @@ package chglog
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -13,12 +14,14 @@ type tagReader struct {
|
|||
client gitcmd.Client
|
||||
format string
|
||||
separator string
|
||||
reFilter *regexp.Regexp
|
||||
}
|
||||
|
||||
func newTagReader(client gitcmd.Client) *tagReader {
|
||||
func newTagReader(client gitcmd.Client, filterPattern string) *tagReader {
|
||||
return &tagReader{
|
||||
client: client,
|
||||
separator: "@@__CHGLOG__@@",
|
||||
reFilter: regexp.MustCompile(filterPattern),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,6 +59,12 @@ func (r *tagReader) ReadAll() ([]*Tag, error) {
|
|||
date = t
|
||||
}
|
||||
|
||||
if r.reFilter != nil {
|
||||
if !r.reFilter.MatchString(name) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
tags = append(tags, &Tag{
|
||||
Name: name,
|
||||
Subject: subject,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue