<commit_before>#!/bin/bash

RED_TEXT_COLOR=$(tput setaf 1)
GREEN_TEXT_COLOR=$(tput setaf 2)
MAGENTA_TEXT_COLOR=$(tput setaf 5)
RESET_TEXT_COLOR=$(tput sgr0)

if [ ! -f "./include/mantella" ]; then
    echo "${RED_TEXT_COLOR}Could not find Mantella. Make sure to start this script within Mantella's root path.${RESET_TEXT_COLOR}";
    exit 1;
fi;

ANY_ERROR_OCCURED=0;
if [ -z "${1}" ] || [ "$1" == "format" ]; then
  FORMAT_ERROR_OCCURED=0;

  echo "${MAGENTA_TEXT_COLOR}Checking format rules${RESET_TEXT_COLOR}";
  FILES=$(find src include -type f);
  NUMBER_OF_FILES=$(echo "${FILES}" | wc -l);
  COUNTER=1;
  
  clang-format -version
  while read file; do
    printf "[%3s%%] " "$(( (COUNTER * 100) / NUMBER_OF_FILES ))"
    
    if [[ `clang-format -output-replacements-xml "${file}" | grep "<replacement " | wc -l` -ne 0 ]]; then
      echo "${RED_TEXT_COLOR}${file}${RESET_TEXT_COLOR} is not properly formatted. Please run '${GREEN_TEXT_COLOR}clang-format -i ${file}${RESET_TEXT_COLOR}'.";
      FORMAT_ERROR_OCCURED=1;
      ANY_ERROR_OCCURED=1;
    else
      printf "\r";
    fi;

    COUNTER=$((++COUNTER));
  done <<< "${FILES})";
  
  if [[ ${FORMAT_ERROR_OCCURED} == 0 ]]; then
    echo "${GREEN_TEXT_COLOR}Everything is fine.${RESET_TEXT_COLOR}";
  fi;
  
  # The whitespace at the end is intentional, in order to override the progress bar ('printf "[%3s%%]"' from above), which is 6 characters long.
  echo "${MAGENTA_TEXT_COLOR}done.${RESET_TEXT_COLOR} ";
fi;
  
if [ -z "${1}" ] || [ "${1}" == "include" ]; then
  INCLUDE_ERROR_OCCURED=0;
  <commit_msg>cleanup<commit_after>#!/bin/bash

RED_TEXT_COLOR=$(tput setaf 1)
GREEN_TEXT_COLOR=$(tput setaf 2)
MAGENTA_TEXT_COLOR=$(tput setaf 5)
RESET_TEXT_COLOR=$(tput sgr0)

if [ ! -f "./include/mantella" ]; then
    echo "${RED_TEXT_COLOR}Could not find Mantella. Make sure to start this script within Mantella's root path.${RESET_TEXT_COLOR}";
    exit 1;
fi;

ANY_ERROR_OCCURED=0;
if [ -z "${1}" ] || [ "$1" == "format" ]; then
  FORMAT_ERROR_OCCURED=0;

  echo "${MAGENTA_TEXT_COLOR}Checking format rules${RESET_TEXT_COLOR}";
  FILES=$(find src include -type f);
  NUMBER_OF_FILES=$(echo "${FILES}" | wc -l);
  COUNTER=1;
  
  while read file; do
    printf "[%3s%%] " "$(( (COUNTER * 100) / NUMBER_OF_FILES ))"
    
    if [[ `clang-format -output-replacements-xml "${file}" | grep "<replacement " | wc -l` -ne 0 ]]; then
      echo "${RED_TEXT_COLOR}${file}${RESET_TEXT_COLOR} is not properly formatted. Please run '${GREEN_TEXT_COLOR}clang-format -i ${file}${RESET_TEXT_COLOR}'.";
      FORMAT_ERROR_OCCURED=1;
      ANY_ERROR_OCCURED=1;
    else
      printf "\r";
    fi;

    COUNTER=$((++COUNTER));
  done <<< "${FILES})";
  
  if [[ ${FORMAT_ERROR_OCCURED} == 0 ]]; then
    echo "${GREEN_TEXT_COLOR}Everything is fine.${RESET_TEXT_COLOR}";
  fi;
  
  # The whitespace at the end is intentional, in order to override the progress bar ('printf "[%3s%%]"' from above), which is 6 characters long.
  echo "${MAGENTA_TEXT_COLOR}done.${RESET_TEXT_COLOR} ";
fi;
  
if [ -z "${1}" ] || [ "${1}" == "include" ]; then
  INCLUDE_ERROR_OCCURED=0;
  
{'fraction_non_alphanumeric': 0.1729903536977492, 'fraction_numerical': 0.014790996784565916, 'mean_word_length': 4.108374384236453, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4963947', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1158, 'n_words': 278}