Last active
August 29, 2015 14:15
-
-
Save pschwede/a4d60e0a03c7a7b0d67e to your computer and use it in GitHub Desktop.
Diff recursively though all subfolders and then plot identity relation with circo (graphviz, dot)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# ======================================== | |
# Diff recursively and then render the identity relation between the files using graphviz circo. | |
# ======================================== | |
# | |
# Go to a folder with your subdirectories you want to compare, then call "diff_circo". | |
# | |
# Copyright (c) 2015, Peter Schwede [email protected] | |
# | |
# | |
# Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided #that the above copyright notice and this permission notice appear in all copies. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED #WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL #DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER #TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
set -e | |
set -x | |
tmpdir=$(mktemp -d) | |
trap 'rm -r $tmpdir' ERR EXIT | |
for n in */; do | |
echo $n | |
done > $tmpdir/nodes.txt | |
for a in */; do | |
a=$(basename $a) | |
while read; do | |
diff -sqr "$a" "$REPLY" || echo -en "" | |
done < <(tail -n +$(ls -1d */ | grep -n "^$a/$" | cut -d':' -f1) <(ls -1d */)) | |
done > $tmpdir/diff.log | |
ls $tmpdir/diff.log | |
cp -v $tmpdir/diff.log diff.log | |
for c in "differ" "identical"; do | |
echo "graph $c {" > $tmpdir/diff.$c.dot | |
awk '/'$c'$/ {print $2, "--", $4}' $tmpdir/diff.log | tr '.' '_' | sed 's/\//__/g' | sed 's/___/__/g' >> $tmpdir/diff.$c.dot | |
echo "}" >> $tmpdir/diff.$c.dot | |
for format in "ps" "png" "svg"; do | |
circo $tmpdir/diff.$c.dot -T$format -o diff.$c.$format | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment