Last active
October 22, 2015 20:19
-
-
Save siliconcow/fc17703c7f123cd943b9 to your computer and use it in GitHub Desktop.
Docker cache optimization (osx)
This file contains 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 | |
#put this in .git/hooks/post-checkout and chmod 755 | |
platform='unknown' | |
unamestr=`uname` | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
touchutil='touch' | |
dateutil='date' | |
elif [[ "$OSTYPE" == darwin* ]]; then | |
brew install coreutils > /dev/null 2>&1 | |
touchutil='gtouch' | |
dateutil='gdate' | |
fi | |
echo "[Zest Hook] Running docker cache optimization..." | |
find . -exec $touchutil -t 201401010000 {} \; | |
for x in $(git ls-tree --full-tree --name-only -r HEAD);\ | |
do $touchutil -t \ | |
$($dateutil -d "$(git log -1 --format=%ci "${x}")" +%y%m%d%H%M.%S) \ | |
"${x}"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment