#!/usr/bin/env bash
set -x -e

source ./functions.sh

cd ..
rm -rf rubyX-tests
mkdir rubyX-tests

if [ -d ruby ]
then
	cd ruby
	git pull -a
	cd ..
else
	git clone https://github.com/ruby/ruby.git
fi

cp -Rp ruby rubyX-tests/rubyX-data
cd rubyX-tests/rubyX-data

pijul init .
for G in $(git log  --pretty=format:%h --reverse); do
	git checkout -q "$G"
	add
	record
done

rm -rf .git
cd ..
pijul clone rubyX-data rubyX-data2
eq 1 "$(diff -qr rubyX-data/ rubyX-data2/ | wc -l)"

cd ..
rm -rf rubyX-tests
echo "All OK."