pkggraph: Add warning when resolving dependency to remote node over local node (#810)

This commit is contained in:
Thomas Crain 2021-03-30 07:59:14 -07:00 коммит произвёл GitHub
Родитель e5957887fe
Коммит 16e63a3f47
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -470,12 +470,14 @@ func (g *PkgGraph) RemovePkgNode(pkgNode *PkgNode) {
func (g *PkgGraph) FindDoubleConditionalPkgNodeFromPkg(pkgVer *pkgjson.PackageVer) (lookupEntry *LookupNode, err error) {
var (
requestInterval, nodeInterval pkgjson.PackageVerInterval
bestLocalNode *LookupNode
)
requestInterval, err = pkgVer.Interval()
if err != nil {
return
}
bestLocalNode = nil
packageNodes := g.lookupTable()[pkgVer.Name]
for _, node := range packageNodes {
if node.RunNode == nil {
@ -489,10 +491,21 @@ func (g *PkgGraph) FindDoubleConditionalPkgNodeFromPkg(pkgVer *pkgjson.PackageVe
}
if nodeInterval.Satisfies(&requestInterval) {
// Only local packages will have a build node
if node.BuildNode != nil {
bestLocalNode = node
}
// Keep going, we want the highest version which satisfies both conditionals
lookupEntry = node
}
}
// If the pkgVer resolves to a remote node, and that node
// is never found during the build, we have no way to
// fall back to the local package at this time.
if bestLocalNode != nil && bestLocalNode != lookupEntry {
logger.Log.Warnf("Resolving '%s' to remote node '%s' instead of local node '%s'", pkgVer, lookupEntry.RunNode.String(), bestLocalNode.RunNode.String())
}
return
}