dag: Fix graph printing type mismatch

Dependencies were being sorted, but their types were not, causing
incorrect printing.
This commit is contained in:
Paul Hinze 2016-07-14 09:32:47 -06:00
parent ddffb47492
commit a4c96e5619
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
1 changed files with 6 additions and 5 deletions

View File

@ -202,16 +202,17 @@ func (g *Graph) StringWithNodeTypes() string {
// Alphabetize dependencies
deps := make([]string, 0, targets.Len())
targetNodes := make([]Vertex, 0, targets.Len())
targetNodes := make(map[string]Vertex)
for _, target := range targets.List() {
deps = append(deps, VertexName(target))
targetNodes = append(targetNodes, target)
dep := VertexName(target)
deps = append(deps, dep)
targetNodes[dep] = target
}
sort.Strings(deps)
// Write dependencies
for i, d := range deps {
buf.WriteString(fmt.Sprintf(" %s - %T\n", d, targetNodes[i]))
for _, d := range deps {
buf.WriteString(fmt.Sprintf(" %s - %T\n", d, targetNodes[d]))
}
}