fix References used by the ReferenceTransformer

There was a bug where all references would be discarded in the case when
a self-reference was encountered. Since a module references all
descendants by it's own path, it returns a self-reference by definition.
This commit is contained in:
James Bardin
2017-11-09 10:36:42 -05:00
parent 7e4dcdb9f0
commit e0ad3300c6

View File

@@ -127,6 +127,7 @@ func (m *ReferenceMap) References(v dag.Vertex) ([]dag.Vertex, []string) {
var matches []dag.Vertex
var missing []string
prefix := m.prefix(v)
for _, ns := range rn.References() {
found := false
for _, n := range strings.Split(ns, "/") {
@@ -139,19 +140,14 @@ func (m *ReferenceMap) References(v dag.Vertex) ([]dag.Vertex, []string) {
// Mark that we found a match
found = true
// Make sure this isn't a self reference, which isn't included
selfRef := false
for _, p := range parents {
// don't include self-references
if p == v {
selfRef = true
break
continue
}
}
if selfRef {
continue
matches = append(matches, p)
}
matches = append(matches, parents...)
break
}