<commit_before>#!/bin/bash

set -e

REALPATH=grealpath
if ! command -v grealpath >/dev/null 2>&1; then
    REALPATH=realpath
fi

SCRIPT_DIR="$(dirname "$("${REALPATH}" "${BASH_SOURCE[0]}")")"
TARGET_SCRIPT="${SCRIPT_DIR}/targets/${TARGET}.sh"

if [[ -n "${TARGET}" ]] && [[ -e "${TARGET_SCRIPT}" ]]; then
    source "${TARGET_SCRIPT}"
else
    echo "Target not defined or invalid!"
    exit 1
fi

set -x

BUILD=0
[[ "x$(type -t build)" = "xfunction" ]] && BUILD=1

DEPLOY=0
[[ "x$(type -t deploy)" = "xfunction" ]] && DEPLOY=1

SOURCE_DIR="$(dirname "${SCRIPT_DIR}")"
BUILD_DIR="${SOURCE_DIR}/build"

default_configure() {
    pushd "${BUILD_DIR}" > /dev/null
    "${SOURCE_DIR}/configure" \
        CFLAGS="-Wall -g -O0" \
        --disable-silent-rules \
        --disable-valgrind \
        --enable-ronn \
        --enable-tests \
        --enable-git-receiver \
        --enable-make \
        --enable-runserver \
        "$@"
    popd > /dev/null
}

rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"

RV=0

if [[ ${BUILD} -eq 1 ]]; then
    pushd "${BUILD_DIR}" > /dev/null
    set +e
    build
    RV=$?
    set -e
    popd > /dev/null
fi

[[ ${DEPLOY} -eq 1 ]] || exit ${RV}

[[ "x${TRAVIS_PULL_REQUEST}" != "xfalse" ]] && exit ${RV}
[[ "x${TRAVIS_BRANCH}" != "xmaster" ]] && [[ "x${TRAVIS_TAG}" != xv* ]] && exit ${RV}

[[ -d "${BUILD_DIR}" ]] || exit ${RV}

FILES=
pushd "${BUILD_DIR}" > /dev/null
deploy || exit ${RV}
popd > /dev/null

set +x

PN="$(grep PACKAGE_TARNAME "${BUILD_DIR}/config.h" | cut -d\" -f2)"
PV="$(grep PACKAGE_VERSION "${BUILD_DIR}/config.h" | cut -d\" -f2)"

do_sha512() {
    pushd "$(dirname ${1})" > /dev/null
    sha512sum "$(basename ${1})"
    popd > /dev/null
}

do_curl() {
    curl \
        --silent \
        --form "project=${PN}" \
        --form "version=${PV}" \<commit_msg>travis: do not exit on build error<commit_after>#!/bin/bash

set -e

REALPATH=grealpath
if ! command -v grealpath >/dev/null 2>&1; then
    REALPATH=realpath
fi

SCRIPT_DIR="$(dirname "$("${REALPATH}" "${BASH_SOURCE[0]}")")"
TARGET_SCRIPT="${SCRIPT_DIR}/targets/${TARGET}.sh"

if [[ -n "${TARGET}" ]] && [[ -e "${TARGET_SCRIPT}" ]]; then
    source "${TARGET_SCRIPT}"
else
    echo "Target not defined or invalid!"
    exit 1
fi

set -x

BUILD=0
[[ "x$(type -t build)" = "xfunction" ]] && BUILD=1

DEPLOY=0
[[ "x$(type -t deploy)" = "xfunction" ]] && DEPLOY=1

SOURCE_DIR="$(dirname "${SCRIPT_DIR}")"
BUILD_DIR="${SOURCE_DIR}/build"

default_configure() {
    pushd "${BUILD_DIR}" > /dev/null
    "${SOURCE_DIR}/configure" \
        CFLAGS="-Wall -g -O0" \
        --disable-silent-rules \
        --disable-valgrind \
        --enable-ronn \
        --enable-tests \
        --enable-git-receiver \
        --enable-make \
        --enable-runserver \
        "$@"
    popd > /dev/null
}

rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}"

RV=0

if [[ ${BUILD} -eq 1 ]]; then
    pushd "${BUILD_DIR}" > /dev/null
    build || RV=1
    popd > /dev/null
fi

[[ ${DEPLOY} -eq 1 ]] || exit ${RV}

[[ "x${TRAVIS_PULL_REQUEST}" != "xfalse" ]] && exit ${RV}
[[ "x${TRAVIS_BRANCH}" != "xmaster" ]] && [[ "x${TRAVIS_TAG}" != xv* ]] && exit ${RV}

[[ -d "${BUILD_DIR}" ]] || exit ${RV}

FILES=
pushd "${BUILD_DIR}" > /dev/null
deploy || exit ${RV}
popd > /dev/null

set +x

PN="$(grep PACKAGE_TARNAME "${BUILD_DIR}/config.h" | cut -d\" -f2)"
PV="$(grep PACKAGE_VERSION "${BUILD_DIR}/config.h" | cut -d\" -f2)"

do_sha512() {
    pushd "$(dirname ${1})" > /dev/null
    sha512sum "$(basename ${1})"
    popd > /dev/null
}

do_curl() {
    curl \
        --silent \
        --form "project=${PN}" \
        --form "version=${PV}" \
{'fraction_non_alphanumeric': 0.2313617606602476, 'fraction_numerical': 0.012379642365887207, 'mean_word_length': 2.729230769230769, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '7443353', 'n_tokens_mistral': 1502, 'n_tokens_neox': 1441, 'n_words': 306}