<commit_before>#!/bin/bash

if [ $# -ne 2 ]
then
    echo "Usage: rust-analyze.sh config-file.json tree_name"
    exit 1
fi

set -e # Errors are fatal
set -x # Show commands

CONFIG_FILE=$(realpath $1)
TREE_NAME=$2

MOZSEARCH_PATH=$(cd $(dirname "$0") && git rev-parse --show-toplevel)
. $MOZSEARCH_PATH/scripts/load-vars.sh $CONFIG_FILE $TREE_NAME

ANALYSIS_DIR=$(find $OBJDIR -type d -name save-analysis || true)

if [ -d "$ANALYSIS_DIR" ]; then
  $MOZSEARCH_PATH/tools/target/release/rust-indexer \
    $FILES_ROOT \
    $ANALYSIS_DIR \
    $INDEX_ROOT/analysis
fi
<commit_msg>Update rust-analyze.sh to handle multiple save-analysis directories<commit_after>#!/bin/bash

if [ $# -ne 2 ]
then
    echo "Usage: rust-analyze.sh config-file.json tree_name"
    exit 1
fi

set -e # Errors are fatal
set -x # Show commands

CONFIG_FILE=$(realpath $1)
TREE_NAME=$2

MOZSEARCH_PATH=$(cd $(dirname "$0") && git rev-parse --show-toplevel)
. $MOZSEARCH_PATH/scripts/load-vars.sh $CONFIG_FILE $TREE_NAME

find $OBJDIR -type d -name save-analysis |
while read ANALYSIS_DIR; do
  $MOZSEARCH_PATH/tools/target/release/rust-indexer \
    "$FILES_ROOT" \
    "$ANALYSIS_DIR" \
    "$INDEX_ROOT/analysis"
done

{'fraction_non_alphanumeric': 0.1389121338912134, 'fraction_numerical': 0.008368200836820083, 'mean_word_length': 3.8032128514056227, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1967838', 'n_tokens_mistral': 475, 'n_tokens_neox': 463, 'n_words': 105}