mirror of
https://github.com/git-chglog/git-chglog.git
synced 2026-01-23 02:15:12 +00:00
feat: First implement
This commit is contained in:
parent
a44743ef3f
commit
6caf676beb
105 changed files with 20966 additions and 0 deletions
48
commit_filter.go
Normal file
48
commit_filter.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package chglog
|
||||
|
||||
func commitFilter(commits []*Commit, filters map[string][]string) []*Commit {
|
||||
res := []*Commit{}
|
||||
|
||||
for _, commit := range commits {
|
||||
include := false
|
||||
|
||||
if len(filters) == 0 {
|
||||
include = true
|
||||
}
|
||||
|
||||
for key, values := range filters {
|
||||
prop, ok := dotGet(commit, key)
|
||||
if !ok {
|
||||
include = false
|
||||
break
|
||||
}
|
||||
|
||||
str, ok := prop.(string)
|
||||
if !ok {
|
||||
include = false
|
||||
break
|
||||
}
|
||||
|
||||
exist := false
|
||||
|
||||
for _, val := range values {
|
||||
if str == val {
|
||||
exist = true
|
||||
}
|
||||
}
|
||||
|
||||
if !exist {
|
||||
include = false
|
||||
break
|
||||
}
|
||||
|
||||
include = true
|
||||
}
|
||||
|
||||
if include {
|
||||
res = append(res, commit)
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue