<commit_before>#!/bin/sh -e

DIRECTORY=$(dirname "${0}")
SCRIPT_DIRECTORY=$(cd "${DIRECTORY}"; pwd)

usage()
{
    echo "Usage: ${0} NAME"
}

# shellcheck source=/dev/null
. "${SCRIPT_DIRECTORY}/../lib/git_lab_tools.sh"

NAME="${1}"

if [ "${NAME}" = "" ]; then
    usage

    exit 1
fi

echo "${NAME}" | grep --quiet / && CONTAINS_SLASH=true || CONTAINS_SLASH=false

if [ "${CONTAINS_SLASH}" = true ]; then
    NAME_WITHOUT_NAMESPACE="${NAME#*/}"
    RESPONSE=$(${REQUEST} "${INTERFACE_LOCATOR}/projects?search=${NAME_WITHOUT_NAMESPACE}")
    IDENTIFIERS=$(echo "${RESPONSE}" | jsawk -n "if (this.path_with_namespace == '${NAME}') out(this.id)")
else
    RESPONSE=$(${REQUEST} "${INTERFACE_LOCATOR}/projects?search=${NAME}")
    IDENTIFIERS=$(echo "${RESPONSE}" | jsawk -n "if (this.name == '${NAME}') out(this.id)")
fi

COUNT=$(echo -n "${IDENTIFIERS}" | grep -c '^') || COUNT=0

if [ "${COUNT}" = 0 ]; then
    echo "Project not found."

    exit 1
elif [ "${COUNT}" = 1 ]; then
    echo "${IDENTIFIERS}"
else
    echo "More than one project returned."

    exit 1
fi<commit_msg>add debug option to save responses<commit_after>#!/bin/sh -e

DIRECTORY=$(dirname "${0}")
SCRIPT_DIRECTORY=$(cd "${DIRECTORY}"; pwd)

usage()
{
    echo "Usage: ${0} NAME"
}

# shellcheck source=/dev/null
. "${SCRIPT_DIRECTORY}/../lib/git_lab_tools.sh"

DEBUG=true
NAME="${1}"

if [ "${NAME}" = "" ]; then
    usage

    exit 1
fi

echo "${NAME}" | grep --quiet / && CONTAINS_SLASH=true || CONTAINS_SLASH=false

if [ "${CONTAINS_SLASH}" = true ]; then
    NAME_WITHOUT_NAMESPACE="${NAME#*/}"
    RESPONSE=$(${REQUEST} "${INTERFACE_LOCATOR}/projects?search=${NAME_WITHOUT_NAMESPACE}")
    IDENTIFIERS=$(echo "${RESPONSE}" | jsawk -n "if (this.path_with_namespace == '${NAME}') out(this.id)")
else
    RESPONSE=$(${REQUEST} "${INTERFACE_LOCATOR}/projects?search=${NAME}")
    IDENTIFIERS=$(echo "${RESPONSE}" | jsawk -n "if (this.name == '${NAME}') out(this.id)")
fi

if [ "${DEBUG}" = true ]; then
    mkdir -p "${SCRIPT_DIRECTORY}/../tmp"
    echo "${RESPONSE}" > "${SCRIPT_DIRECTORY}/../tmp/response.txt"
fi

COUNT=$(echo -n "${IDENTIFIERS}" | grep -c '^') || COUNT=0

if [ "${COUNT}" = 0 ]; then
    echo "Project not found."

    exit 1
elif [ "${COUNT}" = 1 ]; then
    echo "${IDENTIFIERS}"
else
    echo "More than one project returned."

    exit 1
fi
{'fraction_non_alphanumeric': 0.21923076923076923, 'fraction_numerical': 0.007692307692307693, 'mean_word_length': 4.133771929824562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1336014', 'n_tokens_mistral': 893, 'n_tokens_neox': 863, 'n_words': 192}