<commit_before>#!/bin/bash
# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

if (( ${#BASH_SOURCE[@]} == 1 )); then
    echo "This script must be sourced."
    exit 1
fi

if [[ -z $SD_PULL_REQUEST == false ]]; then
    export SHOULD_BUILD=all
    return 0
fi

JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/pulls/$SD_PULL_REQUEST)
PR_TITLE=$(jq -re '.title' <<< "$JSON")

JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/pulls/$SD_PULL_REQUEST/commits)
COMMITS=$(jq -re '.[].sha' <<< "$JSON")

FILES=$(for C in $COMMITS; do JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/commits/$C); jq -re '.files[].filename' <<< "$JSON"; done)

if [[ $PR_TITLE =~ \[run-systemtest\] ]]; then
  SHOULD_BUILD=systemtest
elif [[ -z $FILES ]]; then
  SHOULD_BUILD=all
elif ! grep -v -E "(\.h|\.hh|\.hxx|\.c|\.cpp|\.cxx)$" <<< "$FILES" &> /dev/null; then
  SHOULD_BUILD=cpp
elif ! grep -v -E "(\.java)$" <<< "$FILES" &> /dev/null; then
  SHOULD_BUILD=java<commit_msg>Fix syntax error in detect script.<commit_after>#!/bin/bash
# Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

if (( ${#BASH_SOURCE[@]} == 1 )); then
    echo "This script must be sourced."
    exit 1
fi

if [[ $SD_PULL_REQUEST == false ]]; then
    export SHOULD_BUILD=all
    return 0
fi

JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/pulls/$SD_PULL_REQUEST)
PR_TITLE=$(jq -re '.title' <<< "$JSON")

JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/pulls/$SD_PULL_REQUEST/commits)
COMMITS=$(jq -re '.[].sha' <<< "$JSON")

FILES=$(for C in $COMMITS; do JSON=$(curl -sLf https://api.github.com/repos/vespa-engine/vespa/commits/$C); jq -re '.files[].filename' <<< "$JSON"; done)

if [[ $PR_TITLE =~ \[run-systemtest\] ]]; then
  SHOULD_BUILD=systemtest
elif [[ -z $FILES ]]; then
  SHOULD_BUILD=all
elif ! grep -v -E "(\.h|\.hh|\.hxx|\.c|\.cpp|\.cxx)$" <<< "$FILES" &> /dev/null; then
  SHOULD_BUILD=cpp
elif ! grep -v -E "(\.java)$" <<< "$FILES" &> /dev/null; then
  SHOULD_BUILD=java
{'fraction_non_alphanumeric': 0.208955223880597, 'fraction_numerical': 0.0046641791044776115, 'mean_word_length': 3.7560975609756095, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 7, 'https://': 6, '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': '5198526', 'n_tokens_mistral': 888, 'n_tokens_neox': 819, 'n_words': 197}