489
490
// isCyclic returns true if there is a cycle in the DAG of redirect rules.
492
>
makeEdgeMap := func(rules []*persistencespb.RedirectRule) map[string][]string {
493
>
ret := make(map[string][]string)
494
>
for _, rule := range rules {
495
>
src := rule.GetRule().GetSourceBuildId()
496
>
dst := rule.GetRule().GetTargetBuildId()
497
>
list, ok := ret[src]
498
>
if !ok {
499
>
list = make([]string, 0)
500
>
}
501
>
list = append(list, dst)
502
>
ret[src] = list
503
}
505
}
506
508
>
visited := make(map[string]bool)
509
>
for node := range dag {
510
>
inStack := make(map[string]bool)
511
>
if dfs(node, visited, inStack, dag) {
512
return true
513
}