<commit_before>#!/bin/bash
#
# This script lives at <mountain-gorilla.git/tools/jenkins-build-step.sh>.
# A suggested jenkins build step for an MG component or full SDC build.
#
# See the appropriate jenkins job for the *actual* current build steps:
#   https://jenkins.joyent.us/job/$JOB/configure
#

set -o errexit
unset LD_LIBRARY_PATH   # ensure don't get Java's libs (see OS-703)

echo ""
echo "#----------------------"
start_time=$(date +%s)
last_time=${start_time}

rm -rf MG.last
# Poorman's backup of last build run.
mkdir -p MG && mv MG MG.last
rm -rf MG
git clone <EMAIL>:mountain-gorilla.git MG
cd MG

now_time=$(date +%s)
elapsed=$((${now_time} - ${last_time}))
last_time=${now_time}
echo "TIME: clone MG took ${elapsed} seconds"

LOG=build.log
touch $LOG
exec > >(tee ${LOG}) 2>&1



echo ""
echo "#---------------------- env"

date<commit_msg>RELENG-551: improvements to sdc/manta branch build handling<commit_after>#!/bin/bash
#
# This script lives at <mountain-gorilla.git/tools/jenkins-build-step.sh>.
# A suggested jenkins build step for an MG component or full SDC build.
#
# See the appropriate jenkins job for the *actual* current build steps:
#   https://jenkins.joyent.us/job/$JOB/configure
#

set -o errexit
unset LD_LIBRARY_PATH   # ensure don't get Java's libs (see OS-703)


echo ""
echo "#---------------------- params"
start_time=$(date +%s)
last_time=${start_time}

# If "payload" is defined, we presume this is from a post-receive hook.
# `payload.ref` will defined the git branch. For "release-YYYYMMDD" branches
# (the Joyent engineering convention for release branches) we'll be strict
# and have:
#   TRY_BRANCH=  BRANCH=$branch
# but for other branches we'll be "nice" and use
#   TRY_BRANCH=  BRANCH=master
# which allows, for example, a commit to a feature branch (say "foo") to
# work when ancillary repos (like mountain-gorilla.git and usb-headnode.git)
# don't have that branch.
if [[ -n "$payload" ]]; then
    ref=$(echo "$payload" | json ref)
    if [[ $(echo "$ref" | cut -d/ -f2) != "heads" ]]; then
        echo "error: unexpected ref '$ref': is not 'refs/heads'"
        exit 1
    fi
    BRANCH=$(echo "$ref" | cut -d/ -f3)
    if [[ -z "$(echo $BRANCH | egrep '^release-[0-9]+' || true)" ]]; then
        TRY_BRANCH=$BRANCH
        BRANCH=master
    fi
fi
if [[ -z "$BRANCH" ]]; then
    BRANCH=master
fi
echo "BRANCH: $BRANCH"
echo "TRY_BRANCH: $TRY_BRANCH"


echo ""
echo "#---------------------- mg"

rm -rf MG.last
# Poorman's backup of last build run.
mkdir -p MG && mv MG MG.last
rm -rf MG
git clone <EMAIL>:mountain-gorilla.git MG
cd MG
if [[ -n "$TRY_BRANCH" ]]; then
    git checkout $TRY_BRANCH || git checkout $BRANCH
else
    git checkout $BRANCH
fi

now_time=$(date +%s)
elapsed=$((${now_time} - ${last_time}))
last_time=${now_time}
echo "TIME: clone MG took ${elapsed} seconds"

LOG=build.log
touch $LOG
exec > >(tee ${LOG}) 2>&1



echo ""
echo "#---------------------- env"

date
{'fraction_non_alphanumeric': 0.17684996605566872, 'fraction_numerical': 0.006109979633401222, 'mean_word_length': 3.203994293865906, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '2460443', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1029, 'n_words': 341}