<commit_before>#!/usr/bin/env bash

##
# Downloads a custom badge from shields.io
#
# All credit goes to the awesome guys at shields.io!
#
# @see     http://shields.io/
#
# @author  <NAME>
# @link    http://picocms.org
# @license http://opensource.org/licenses/MIT
#

set -e

# parameters
BADGE_FILE_PATH="$1"    # target file path
BADGE_SUBJECT="$2"      # subject (left half) of the badge
BADGE_STATUS="$3"       # status (right half) of the badge
BADGE_COLOR="$4"        # color of the badge

# print parameters
echo "Generating badge..."
printf 'BADGE_FILE_PATH="%s"\n' "$BADGE_FILE_PATH"
printf 'BADGE_SUBJECT="%s"\n' "$BADGE_SUBJECT"
printf 'BADGE_STATUS="%s"\n' "$BADGE_STATUS"
printf 'BADGE_COLOR="%s"\n' "$BADGE_COLOR"
echo

# download badge from shields.io
printf 'Downloading badge...\n'
TMP_BADGE="$(mktemp -u)"

wget -O "$TMP_BADGE" \
    "https://img.shields.io/badge/$BADGE_SUBJECT-$BADGE_STATUS-$BADGE_COLOR.svg"

# validate badge
if [ ! -f "$TMP_BADGE" ]; then
    printf 'Unable to generate badge; skipping...\n\n'
    exit 0
fi

# MIME type image/svg+xml isn't supported at the moment
#
#TMP_BADGE_MIME="$(file --mime-type "$TMP_BADGE" | cut -d ' ' -f 2)"
#if [ "$TMP_BADGE_MIME" != "image/svg+xml" ]; then
#    echo "Generated badge should be of type 'image/svg+xml', '$TMP_BADGE_MIME' given; aborting...\n" >&2
#    exit 1
#fi

# deploy badge
mv "$TMP_BADGE" "$BADGE_FILE_PATH"

echo
<commit_msg>_build/generate-badge.sh: Skip on emty file<commit_after>#!/usr/bin/env bash

##
# Downloads a custom badge from shields.io
#
# All credit goes to the awesome guys at shields.io!
#
# @see     http://shields.io/
#
# @author  <NAME>
# @link    http://picocms.org
# @license http://opensource.org/licenses/MIT
#

set -e

# parameters
BADGE_FILE_PATH="$1"    # target file path
BADGE_SUBJECT="$2"      # subject (left half) of the badge
BADGE_STATUS="$3"       # status (right half) of the badge
BADGE_COLOR="$4"        # color of the badge

# print parameters
echo "Generating badge..."
printf 'BADGE_FILE_PATH="%s"\n' "$BADGE_FILE_PATH"
printf 'BADGE_SUBJECT="%s"\n' "$BADGE_SUBJECT"
printf 'BADGE_STATUS="%s"\n' "$BADGE_STATUS"
printf 'BADGE_COLOR="%s"\n' "$BADGE_COLOR"
echo

# download badge from shields.io
printf 'Downloading badge...\n'
TMP_BADGE="$(mktemp -u)"

wget -O "$TMP_BADGE" \
    "https://img.shields.io/badge/$BADGE_SUBJECT-$BADGE_STATUS-$BADGE_COLOR.svg"

# validate badge
if [ ! -f "$TMP_BADGE" ] || [ ! -s "$TMP_BADGE" ]; then
    printf 'Unable to generate badge; skipping...\n\n'
    exit 0
fi

# MIME type image/svg+xml isn't supported at the moment
#
#TMP_BADGE_MIME="$(file --mime-type "$TMP_BADGE" | cut -d ' ' -f 2)"
#if [ "$TMP_BADGE_MIME" != "image/svg+xml" ]; then
#    echo "Generated badge should be of type 'image/svg+xml', '$TMP_BADGE_MIME' given; aborting...\n" >&2
#    exit 1
#fi

# deploy badge
mv "$TMP_BADGE" "$BADGE_FILE_PATH"

echo

{'fraction_non_alphanumeric': 0.16441675320179994, 'fraction_numerical': 0.005538248528902735, 'mean_word_length': 3.8900169204737733, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '83831', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1097, 'n_words': 280}