notcurses/tools/function-summary/compare-outputs.sh
joseLuís 7b9a38d2f1 rust: update function-summary system of scripts
- update script `function_summary.sh`
- new script `compare_outputs.sh` to compile the differences between versions
- create changes files that summarizes diffs between versions
- remove outdated ouput folders
2021-04-06 18:38:09 +02:00

66 lines
1.3 KiB
Bash
Executable File

#/usr/bin/env bash
#
# compares the changes betwee two output folders
PATH1=$1
PATH2=$2
if [[ -z $PATH1 ]]; then
echo "It's necessary to provide two paths to compare. 0 paths provided"
exit 1
fi
if [[ ! -d $PATH1 ]]; then
echo "The first path doesn't exist."
exit 1
fi
if [[ -z $PATH2 ]]; then
echo "It's necessary to provide two paths to compare. Only 1 path provided."
exit 1
fi
if [[ ! -d $PATH2 ]]; then
echo "The second path doesn't exist."
exit 1
fi
# this line is to activate diff syntax highlighting
echo -e "0d0\n"
echo -e "Differences between files:\n=========================="
#DIFFLIST=$(diff -qr "$PATH1" "$PATH2" | grep ^Files | cut -d' ' -f 2,4)
DIFFLIST=$(diff -qr "$PATH1" "$PATH2" | grep ^Files | cut -d' ' -f 2,4 | grep -v STATS)
echo "$DIFFLIST"
echo -e "\nbroken down:\n============"
OLDIFS=$IFS
IFS=$'\n'
for d in $DIFFLIST; do
d1=$(echo $d | cut -d' ' -f1)
d2=$(echo $d | cut -d' ' -f2)
echo -e "\ndiff $d1 $d2:"
diff $d1 $d2
done
echo -e "\nOnly in one path:\n================="
UNIQUELIST=$(diff -qr "$PATH1" "$PATH2" | grep ^Only)
echo "$UNIQUELIST"
echo -e "\ndisplay contents:\n================="
for u in $UNIQUELIST; do
u1=$(echo $u | cut -d' ' -f3| tr ':' '/' )
u2=$(echo $u | cut -d' ' -f4)
path="${u1}${u2}"
echo -e "\ncat $path:\n-------------------"
cat $path
done
IFS=$OLDIFS