<commit_before>#!/bin/bash

THIS_SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${THIS_SCRIPTDIR}/_bash_utils/utils.sh"
source "${THIS_SCRIPTDIR}/_bash_utils/formatted_output.sh"

# init / cleanup the formatted output
echo "" > "${formatted_output_file_path}"

# Input validation
# - required
if [  -z "$HIPCHAT_TOKEN" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_TOKEN` is not provided!*'
  exit 1
fi

if [ -z "$HIPCHAT_ROOMID" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_ROOMID` is not provided!*'
  exit 1
fi

if [ -z "$HIPCHAT_FROMNAME" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_FROMNAME` is not provided!*'
  exit 1
fi

if [ -z "$HIPCHAT_MESSAGE" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_MESSAGE` is not provided!*'
  exit 1
fi

# - optional
if [ -z "$HIPCHAT_MESSAGE_COLOR" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_MESSAGE_COLOR` is not provided!*'
fi

if [ -z "$HIPCHAT_ERROR_FROMNAME" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_ERROR_FROMNAME` is not provided!*'
fi

if [ -z "$HIPCHAT_ERROR_MESSAGE" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_ERROR_MESSAGE` is not provided!*'
fi

# Build failed mode
isBuildFailedMode="0"
if [ -n "$STEPLIB_BUILD_STATUS" ] ; then
  isBuildFailedMode="${STEPLIB_BUILD_STATUS}"
fi

# Curl params
message="${HIPCHAT_MESSAGE}"
if [[ "${isBuildFailedMode}" == "1" ]] ; then
  if [ -n "$HIPCHAT_ERROR_FROMNAME" ] ; then
    message="${HIPCHAT_ERROR_FROMNAME}"
  fi
fi

from_name="${HIPCHAT_FROMNAME}"
if [[ "${isBuildFailedMode}" == "1" ]] ; then
  if [ -n "$HIPCHAT_ERROR_FROMNAME" ] ; then
    from_name="${HIPCHAT_ERROR_FROMNAME}"
  fi
fi

msg_color='yellow'
if [ -n "$HIPCHAT_MESSAGE_COLOR" ] ; then<commit_msg>build failed message, and from name fix<commit_after>#!/bin/bash

THIS_SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${THIS_SCRIPTDIR}/_bash_utils/utils.sh"
source "${THIS_SCRIPTDIR}/_bash_utils/formatted_output.sh"

# init / cleanup the formatted output
echo "" > "${formatted_output_file_path}"

# Input validation
# - required
if [  -z "$HIPCHAT_TOKEN" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_TOKEN` is not provided!*'
  exit 1
fi

if [ -z "$HIPCHAT_ROOMID" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_ROOMID` is not provided!*'
  exit 1
fi

if [ -z "$HIPCHAT_FROMNAME" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_FROMNAME` is not provided!*'
  exit 1
fi

if [ -z "$HIPCHAT_MESSAGE" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_MESSAGE` is not provided!*'
  exit 1
fi

# - optional
if [ -z "$HIPCHAT_MESSAGE_COLOR" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_MESSAGE_COLOR` is not provided!*'
fi

if [ -z "$HIPCHAT_ERROR_FROMNAME" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_ERROR_FROMNAME` is not provided!*'
fi

if [ -z "$HIPCHAT_ERROR_MESSAGE" ] ; then
  write_section_to_formatted_output '*Notice: `$HIPCHAT_ERROR_MESSAGE` is not provided!*'
fi

# Build failed mode
isBuildFailedMode="0"
if [ -n "$STEPLIB_BUILD_STATUS" ] ; then
  isBuildFailedMode="${STEPLIB_BUILD_STATUS}"
fi

# Curl params
message="${HIPCHAT_MESSAGE}"
if [[ "${isBuildFailedMode}" == "1" ]] ; then
  if [ -n "$HIPCHAT_ERROR_MESSAGE" ] ; then
    message="${HIPCHAT_ERROR_MESSAGE}"
  fi
fi

from_name="${HIPCHAT_FROMNAME}"
if [[ "${isBuildFailedMode}" == "1" ]] ; then
  if [ -n "$HIPCHAT_ERROR_FROMNAME" ] ; then
    from_name="${HIPCHAT_ERROR_FROMNAME}"
  fi
fi

msg_color='yellow'
if [ -n "$HIPCHAT_MESSAGE_COLOR" ] ; then
{'fraction_non_alphanumeric': 0.14359391965255158, 'fraction_numerical': 0.004343105320304018, 'mean_word_length': 5.5452930728241565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1603459', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1443, 'n_words': 299}