<commit_before>#!/bin/bash

clone() {
  local repo=$1
  local dir=$2
  local root="https://github.com/ImageMagick"

  echo ''
  echo "Cloning $1"

  if [ ! -d "$dir" ]; then
    git clone $root/$repo.git $dir
    if [ $? != 0 ]; then echo "Error during checkout"; exit; fi
  fi
  cd $dir
  git pull origin master
  cd ..
}

#clone and check out a specific commit
clone_commit()
{
  local repo=$1
  local commit=$2
  local dir=$3
  if [ -z $dir ]; then dir=$repo; fi

  clone $repo $dir

  cd $dir
  git checkout $commit
  cd ..
}

#clone and check out a specific date
clone_date()
{
  local repo=$1
  local date=$2
  local dir=$3
  if [ -z $dir ]; then dir=$repo; fi

  clone $repo $dir

  cd $dir
  git checkout `git rev-list -n 1 --before="$date" origin/master`
  cd ..
}

if [ ! -d "ImageMagick" ]; then
  mkdir ImageMagick
fi

cd ImageMagick

clone_commit 'ImageMagick' '9fdda6391e38aaad3bfd6a30bd6a72bd31aeee02'

# get a commit date from the current ImageMagick checkout
cd ImageMagick
declare -r commitDate=`git log -1 --format=%ci`
echo "Set latest commit date as $commitDate" 
cd ..

if [ "$1" != "Linux" ] && [ "$1" != "Windows" ]; then
  exit
fi

clone_date 'jpeg-turbo' "$commitDate" 'jpeg'
clone_date 'libxml' "$commitDate"
clone_date 'openjpeg' "$commitDate"
clone_date 'png' "$commitDate"
clone_date 'tiff' "$commitDate"
clone_date 'webp' "$commitDate"
clone_date 'zlib' "$commitDate"

if [ "$1" != "Windows" ]; then
  exit
fi

clone_date 'cairo' "$commitDate"
clone_date 'croco' "$commitDate"
clone_date 'exr' "$commitDate"
clone_date 'ffi' "$commitDate"
clone_date 'flif' "$commitDate"
clone_date 'glib' "$commitDate"
clone_date 'jp2' "$commitDate"
clone_date 'lcms' "$commitDate"
clone_date 'libde265' "$commitDate"
clone_date 'libraw' "$commitDate"
clone_date 'librsvg' "$commitDate"
clone_date 'lqr' "$commitDate"
clone_date 'pango' "$commitDate"
clone_date 'pixman' "$commitDate"
clone_date 'ttf' "$commitDate"
clone_date 'VisualMagick' "$commitDate"

rm -rf VisualMagick/bzlib
rm -rf VisualMagick/dcraw
rm -rf VisualMagick/demos
rm -rf VisualMagick/fuzz
rm -rf VisualMagick/ImageMagickObject
rm -rf VisualMagick/IMDisplay
rm -rf VisualMagick/iptcutil
rm -rf VisualMagick/liblzma
rm -rf VisualMagick/Magick++
rm -rf VisualMagick/NtMagick<commit_msg>Clone lcms for the Linux build.<commit_after>#!/bin/bash

clone() {
  local repo=$1
  local dir=$2
  local root="https://github.com/ImageMagick"

  echo ''
  echo "Cloning $1"

  if [ ! -d "$dir" ]; then
    git clone $root/$repo.git $dir
    if [ $? != 0 ]; then echo "Error during checkout"; exit; fi
  fi
  cd $dir
  git pull origin master
  cd ..
}

#clone and check out a specific commit
clone_commit()
{
  local repo=$1
  local commit=$2
  local dir=$3
  if [ -z $dir ]; then dir=$repo; fi

  clone $repo $dir

  cd $dir
  git checkout $commit
  cd ..
}

#clone and check out a specific date
clone_date()
{
  local repo=$1
  local date=$2
  local dir=$3
  if [ -z $dir ]; then dir=$repo; fi

  clone $repo $dir

  cd $dir
  git checkout `git rev-list -n 1 --before="$date" origin/master`
  cd ..
}

if [ ! -d "ImageMagick" ]; then
  mkdir ImageMagick
fi

cd ImageMagick

clone_commit 'ImageMagick' '9fdda6391e38aaad3bfd6a30bd6a72bd31aeee02'

# get a commit date from the current ImageMagick checkout
cd ImageMagick
declare -r commitDate=`git log -1 --format=%ci`
echo "Set latest commit date as $commitDate" 
cd ..

if [ "$1" != "Linux" ] && [ "$1" != "Windows" ]; then
  exit
fi

clone_date 'jpeg-turbo' "$commitDate" 'jpeg'
clone_date 'lcms' "$commitDate"
clone_date 'libxml' "$commitDate"
clone_date 'openjpeg' "$commitDate"
clone_date 'png' "$commitDate"
clone_date 'tiff' "$commitDate"
clone_date 'webp' "$commitDate"
clone_date 'zlib' "$commitDate"

if [ "$1" != "Windows" ]; then
  exit
fi

clone_date 'cairo' "$commitDate"
clone_date 'croco' "$commitDate"
clone_date 'exr' "$commitDate"
clone_date 'ffi' "$commitDate"
clone_date 'flif' "$commitDate"
clone_date 'glib' "$commitDate"
clone_date 'jp2' "$commitDate"
clone_date 'libde265' "$commitDate"
clone_date 'libraw' "$commitDate"
clone_date 'librsvg' "$commitDate"
clone_date 'lqr' "$commitDate"
clone_date 'pango' "$commitDate"
clone_date 'pixman' "$commitDate"
clone_date 'ttf' "$commitDate"
clone_date 'VisualMagick' "$commitDate"

rm -rf VisualMagick/bzlib
rm -rf VisualMagick/dcraw
rm -rf VisualMagick/demos
rm -rf VisualMagick/fuzz
rm -rf VisualMagick/ImageMagickObject
rm -rf VisualMagick/IMDisplay
rm -rf VisualMagick/iptcutil
rm -rf VisualMagick/liblzma
rm -rf VisualMagick/Magick++
rm -rf VisualMagick/NtMagick
{'fraction_non_alphanumeric': 0.13718173836698858, 'fraction_numerical': 0.01624231782265145, 'mean_word_length': 4.3674911660777385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '945332', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1687, 'n_words': 506}