Skip to content

Commit

Permalink
判断多个组件名称
Browse files Browse the repository at this point in the history
  • Loading branch information
645775992 committed Jun 1, 2023
1 parent c42adbb commit acc7871
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
7 changes: 4 additions & 3 deletions fix/file_fix_maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (p *mavenParams) parsePropertyNode(params FixParams, pomPathList []string)
propertiesChilds := xmlquery.Find(node0, "child::*")
ok:
for _, item := range propertiesChilds {
compName := ""
compName := make([]string, 0)
for _, version := range versions {
if "${"+item.Data+"}" != version.InnerText() {
continue
Expand All @@ -176,9 +176,9 @@ func (p *mavenParams) parsePropertyNode(params FixParams, pomPathList []string)
if artifactId == nil {
break ok
}
compName = groupId.InnerText() + ":" + artifactId.InnerText()
compName = append(compName, groupId.InnerText()+":"+artifactId.InnerText())
}
if compName == "" {
if len(compName) == 0 {
continue
}

Expand All @@ -189,6 +189,7 @@ func (p *mavenParams) parsePropertyNode(params FixParams, pomPathList []string)
TagName: item.Data,
PomPath: pomPath,
CompName: compName,
//CompName: nil,
}
if models, ok := p.propertyMap[item.Data]; ok {
models = append(models, model)
Expand Down
2 changes: 1 addition & 1 deletion fix/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ type PropertyModel struct {
OldVersion string
TagName string
PomPath string
CompName string
CompName []string
}
9 changes: 9 additions & 0 deletions fix/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,12 @@ func RunGitCommand(ctx context.Context, path, name string, arg ...string) (strin
return string(out), nil
}
}

func IsInList[T int | string | int64](list []T, num T) bool {
for _, n := range list {
if n == num {
return true
}
}
return false
}
2 changes: 1 addition & 1 deletion fix/xml_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (l *ChildXMLListener) EnterElement(ctx *parser.ElementContext) {

if propertyModel, ok := l.modelMap[model.OldVersion]; ok {
for _, m := range propertyModel {
if m.OldVersion == l.compVersion && m.CompName == l.compName {
if m.OldVersion == l.compVersion && IsInList(m.CompName, l.compName) {

newModel := FixModel{
Line: m.Line,
Expand Down

0 comments on commit acc7871

Please sign in to comment.