/ devops / misc / check-repo-cycles.jq
check-repo-cycles.jq
 1  .state |
 2  to_entries[] | .key as $ty     | .value |
 3  to_entries[] | .key as $list   | .value as $m | .value |
 4  ("\($list): \($m|length) size" | debug) as $_ |
 5  to_entries[] | .key as $ngram  | .value |
 6  select(.root) | debug |
 7  select(                        # We keep only records with errors
 8    .root and                    # We need .root
 9    (
10      $m[.root].root != null or  # A root should have no root itself
11      .parent != .root and       # We need .parent different .root
12      $m[.parent].root != .root  # The parent's root should the same root.
13    )
14  ) |
15  {$ty, $list, $ngram, data: .}