// 执行下面两行命令 git config --global merge.version_current.name "choose current when parent version and version conflict" git config --global merge.version_current.driver "/home/relengxing/app/version_current %O %A %B"
var ancestorPom gopom.Project var currentPom gopom.Project var otherPom gopom.Project xml.Unmarshal(ancestorBuf, &ancestorPom) xml.Unmarshal(currentBuf, ¤tPom) xml.Unmarshal(otherBuf, &otherPom)
var parentVerion *string = nil if currentPom.Parent != nil && *currentPom.Parent.Version != *otherPom.Parent.Version { parentVerion = currentPom.Parent.Version } var version *string = nil if *currentPom.Version != *otherPom.Version { version = currentPom.Version } versionFmt := "<version>%s</version>" if parentVerion != nil { otherStr = strings.Replace(otherStr, fmt.Sprintf(versionFmt, *otherPom.Parent.Version), fmt.Sprintf(versionFmt, *parentVerion), 1) } if version != nil { otherStr = strings.Replace(otherStr, fmt.Sprintf(versionFmt, *otherPom.Version), fmt.Sprintf(versionFmt, *version), 1) } // 重写文件 os.WriteFile(other, []byte(otherStr), os.ModePerm)
//git merge-file -L current -L ancestor -L other $2 $1 $3