dot

packages and services management
Log | Files | Refs | README

commit 86c63214940716d937205493e4d9adc1c2bae487
parent ff55bd7e5bdf95f484a4adb786d6aa312e57bc2e
Author: josuah <mail@josuah.net>
Date:   Mon,  6 Feb 2017 01:56:16 +0100

optimise version performance by looking at the dates

Diffstat:
Mbin/version | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/bin/version b/bin/version @@ -59,21 +59,29 @@ new() { printf 'making a new revision\n' - find . -type f $(exclude .git .version) -print0 | sort -z | - xargs -0 sha256sum | tee -a .version/tmp | while read -r hash path + [ -f .version/history ] && old="$(tail -n 1 .version/history)" || old='' + + find . -type f $(exclude .git .version) | while IFS='' read -r path do + [ "$old" ] && [ ".version/rev/$old" -nt "$path" ] && + hash="$(grep -F " $path" ".version/rev/$old")" || + hash="$(sha256sum "$path")" + hash="${hash%% *}" + [ -f ".version/obj/$hash" ] || cp "$path" ".version/obj/$hash" - done + + printf '%s %s\n' "$hash" "$path" + printf . 1>&2 + done | sort > .version/tmp new="$(sha256sum .version/tmp)" && new="${new%% *}" || exit 1 mv -f .version/tmp ".version/rev/$new" chmod -w .version/obj/* .version/rev/* - [ -f .version/history ] && old="$(tail -n 1 .version/history)" || old='' [ -f .version/history ] && [ "$new" = "$old" ] || printf '%s\n' "$new" >> .version/history - printf 'old %s\nnew %s\n' "$old" "$new" + printf '\nold %s\nnew %s\n' "$old" "$new" }