<commit_before>declare -A refcache=()

remote_get_all_refs() {
  local remote=$1

  if [[ -z ${refcache["$remote"]} ]]; then
    refcache["$remote"]=$(git ls-remote "$remote" 'refs/heads/packages/*' |
        awk '{ sub(/refs\/heads\//, "", $2); print $2 }')
  fi

  mapfile -t "$2" <<<"${refcache["$remote"]}"
}

remote_has_package() {
  local remote=$1 pkgname=$2 refs

  remote_get_all_refs "$remote" refs

  in_array "$remote/$pkgname" "${refs[@]}"
}

remote_is_tracking() {
  local repo=$1 pkgname=$2

  git show-ref -q "$repo/packages/$pkgname"
}

remote_get_tracked_refs() {
  local remote=$1

  mapfile -t "$2" < <(git branch --remote 2>/dev/null |
      awk -F'( +|/)' -v "remote=$1" \
        '$2 == remote && $3 == "packages" { print "packages/" $4 }')<commit_msg>cache even empty replies from the remote<commit_after>declare -A refcache=()

remote_get_all_refs() {
  local remote=$1

  if [[ -z ${refcache["$remote"]+cached} ]]; then
    refcache["$remote"]=$(git ls-remote "$remote" 'refs/heads/packages/*' |
        awk '{ sub(/refs\/heads\//, "", $2); print $2 }')
  fi

  mapfile -t "$2" <<<"${refcache["$remote"]}"
}

remote_has_package() {
  local remote=$1 pkgname=$2 refs

  remote_get_all_refs "$remote" refs

  in_array "$remote/$pkgname" "${refs[@]}"
}

remote_is_tracking() {
  local repo=$1 pkgname=$2

  git show-ref -q "$repo/packages/$pkgname"
}

remote_get_tracked_refs() {
  local remote=$1

  mapfile -t "$2" < <(git branch --remote 2>/dev/null |
      awk -F'( +|/)' -v "remote=$1" \
        '$2 == remote && $3 == "packages" { print "packages/" $4 }')
{'fraction_non_alphanumeric': 0.22032828282828282, 'fraction_numerical': 0.01893939393939394, 'mean_word_length': 3.541547277936963, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '451687', 'n_tokens_mistral': 626, 'n_tokens_neox': 588, 'n_words': 134}