Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

chore(cache): helper script enhancements #2210

Merged
merged 1 commit into from
Aug 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions scripts/cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";;
Expand All @@ -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"
Expand All @@ -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