chore(cache): helper script enhancements (#2210)

This commit is contained in:
Patrice Chalin 2016-08-26 16:36:13 -07:00 committed by Kathy Walrath
parent 3baea41801
commit b992c55e42
1 changed files with 16 additions and 6 deletions

View File

@ -42,7 +42,7 @@ function cacheRefresh() {
if [[ -e $srcPath ]]; then
[[ -d "$destDir" ]] || (set -x; mkdir $destDir);
case "$f" in
($FILE_PATTERN)
(*$FILE_PATTERN*)
(set -x; cp $srcPath $destPath);;
(*)
echo "SKIPPED $f";;
@ -56,11 +56,20 @@ function cacheRefresh() {
[[ $allFound ]] || exit 1;
}
function cacheDiff() {
function cacheDiffSummary() {
diff -qr -x "_*.*" "$CACHE/" "$LATEST/" | \
grep -v "^Only in"
}
function cacheDiff() {
local FILES="*$1*"
cd $CACHE;
# List files
find . -name "$FILES" ! -name "*~" -exec diff -q {} ../latest/{} \;
# Show differences
find . -name "$FILES" ! -name "*~" -exec diff {} ../latest/{} \;
}
function usage() {
echo "Usage: cache.sh [-d | -l | -r pattern]"
echo " -d diff cache and latest subdirectories"
@ -69,8 +78,9 @@ function usage() {
}
case "$1" in
(-r) shift; cacheRefresh $@;;
(-d) shift; cacheDiff $@;;
(-l) shift; printf "$FILES\n\n";;
(*) usage;
(-r|--refresh) shift; cacheRefresh $@;;
(-ds|--diff-summary) shift; cacheDiffSummary $@;;
(-d|--diff) shift; cacheDiff $@;;
(-l) shift; printf "$FILES\n\n";;
(*) usage;
esac