Commit 8aa24d81 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Adding handling of externals

parent a53ae14a
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -52,6 +52,33 @@ if ! ls | grep -Eq '\.ya?ml$|\.json$'; then
    exit 0
fi

#Check if externals directory exists and contains yaml files
if [ -d "externals" ] && [ -n "$(find externals -name '*.yaml')" ]; then
    echo "Processing external YAML files..."
    for external_file in externals/*.yaml; do
        base_name=$(basename "$external_file")
        if [ -f "./$base_name" ]; then
            # Get last commit timestamps for both files
            external_timestamp=$(cd externals && git log -1 --format=%ct "$(basename $external_file)")
            current_timestamp=$(git log -1 --format=%ct "$base_name" 2>/dev/null || echo "0")
            
            if [ "$external_timestamp" -gt "$current_timestamp" ]; then
                echo "Updating $base_name from externals (newer version found in Git history)"
                cp "$external_file" "./$base_name"
            else
                echo "Keeping existing $base_name (newer or same age in Git history)"
            fi
        else
            # File doesn't exist in current directory, copy it
            echo "Copying new file $base_name from externals"
            cp "$external_file" "./"
        fi
    done
else
    echo "No external YAML files to process"
fi


TMP_FULL_LOG=$(mktemp)
TMP_ERR_LOG=$(mktemp)
fres=0