<commit_before>#!/bin/sh

PLUGINFILE=SageTVPluginsV9.xml
PLUGINMD5=SageTVPluginsV9.md5
TMPFILE=SageTVPluginsV9TMP.xml
DATE=`date +%Y.%0m%0d.%0H%0M`
FAILED=""

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $TMPFILE
echo "<PluginRepository version=\"${DATE}\">" >> $TMPFILE

# finding regular xml manifests
for file in `find plugins/ -name '*.xml'` ; do
    # validate the xml we just got
    xmllint --noout $file
    if [ $? -eq 0 ] ; then
      echo "Adding Plugin $file"
      cat $file | grep -v '<?xml ' >> $TMPFILE
    else
      FAILED="${FAILED} ${file}"
      echo "XML File for ${file} is not valid.  Skipping..." >&2
    fi
done


# resolve .url locators
mkdir tmp
cd tmp
for file in `find ../plugins/ -name '*.url'` ; do
    if [ -e tmp.xml ] ; then
       rm tmp.xml
    fi
    url=`cat $file | head -n1`
    echo "Resolving Reference URL $url"
    wget -O tmp.xml "$url"
    if [ $? -ne 0 ] ; then
        FAILED="${FAILED} ${file}"
        echo "Failed to resolve $url in ${file}.  Skipping..."
    else
        # validate the xml we just got
        xmllint --noout tmp.xml
        if [ $? -eq 0 ]
        then
          echo "Adding Plugin from $url"
          cat tmp.xml | grep -v '<?xml ' >> ../$TMPFILE
        else
          FAILED="${FAILED} ${file}"
          echo "XML File for ${url} is not valid.  Skipping ${file} ..." >&2
        fi
    fi
done
cd ..
rm -rf tmp

echo '</PluginRepository>' >> $TMPFILE

# now validate the entire composited xml file to make sure it is valid
xmllint --noout $TMPFILE
if [ $? -eq 0 ]; then
  rm $PLUGINFILE
  mv $TMPFILE $PLUGINFILE

  # generate the md5 checksum<commit_msg>Added Fuzzy's diff check to abort early if no changes<commit_after>#!/bin/bash

PLUGINFILE=SageTVPluginsV9.xml
PLUGINMD5=SageTVPluginsV9.md5
TMPFILE=SageTVPluginsV9TMP.xml
DATE=`date +%Y.%0m%0d.%0H%0M`
FAILED=""

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $TMPFILE
echo "<PluginRepository version=\"${DATE}\">" >> $TMPFILE

# finding regular xml manifests
for file in `find plugins/ -name '*.xml'` ; do
    # validate the xml we just got
    xmllint --noout $file
    if [ $? -eq 0 ] ; then
      echo "Adding Plugin $file"
      cat $file | grep -v '<?xml ' >> $TMPFILE
    else
      FAILED="${FAILED} ${file}"
      echo "XML File for ${file} is not valid.  Skipping..." >&2
    fi
done


# resolve .url locators
mkdir tmp
cd tmp
for file in `find ../plugins/ -name '*.url'` ; do
    if [ -e tmp.xml ] ; then
       rm tmp.xml
    fi
    url=`cat $file | head -n1`
    echo "Resolving Reference URL $url"
    wget -O tmp.xml "$url"
    if [ $? -ne 0 ] ; then
        FAILED="${FAILED} ${file}"
        echo "Failed to resolve $url in ${file}.  Skipping..."
    else
        # validate the xml we just got
        xmllint --noout tmp.xml
        if [ $? -eq 0 ]
        then
          echo "Adding Plugin from $url"
          cat tmp.xml | grep -v '<?xml ' >> ../$TMPFILE
        else
          FAILED="${FAILED} ${file}"
          echo "XML File for ${url} is not valid.  Skipping ${file} ..." >&2
        fi
    fi
done
cd ..
rm -rf tmp

echo '</PluginRepository>' >> $TMPFILE

# before we carry on, let's validate if anything actually changed.
diff <(grep -v "<PluginRepository" $PLUGINFILE) <(grep -v "<PluginRepository" $TMPFILE) > /dev/null 2>&1
if [ $? -eq 0 ]; then
    echo "Nothing Changed, so let's exit"
    rm -f $TMPFILE
    exit 0;
fi

# it appears that we have some updates, so, let's validate
# now validate the entire composited xml file to make sure it is valid
xmllint --noout $TMPFILE
if [ $? -eq 0 ]; then
  rm $PLUGINFILE
  mv $TMPFILE $PLUGINFILE

  # generate the md5 checksum
{'fraction_non_alphanumeric': 0.14704271631982474, 'fraction_numerical': 0.012048192771084338, 'mean_word_length': 2.391829155060353, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 2, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 36}, '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': '5586580', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1288, 'n_words': 441}