dot

packages and services management
Log | Files | Refs | README

commit ffcbb2218a498d890981da214e0ef5e336bb2b82
parent e38e6aca3be5145438248d840c736bfc3353558e
Author: Josuah Demangeonā  ā µ <mail@josuah.net>
Date:   Wed, 22 Mar 2017 20:23:53 +0100

Updated version

Diffstat:
Mbin/io-file | 2+-
Mbin/version | 25+++++++------------------
2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/bin/io-file b/bin/io-file @@ -36,7 +36,7 @@ main() mkdir -p "$CACHE" touch "$CACHE/io/files" - file="$(path "$1")" + [ "$1" = '.' ] && file="$(path "$(io-path)")" || file="$(path "$1")" # terminal name printf '\033]0;%s\007' "$file" diff --git a/bin/version b/bin/version @@ -58,29 +58,18 @@ new() { printf 'making a new revision\n' - [ -f .version/history ] && old="$(tail -n 1 .version/history)" || old='' - - find . -type f $(exclude .git .version) | while IFS='' read -r path + find . -type f $(exclude .git .version) | sort | xargs sha256sum | + tee .version/tmp | while read -r hash 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" - - printf '%s %s\n' "$hash" "$path" - printf . 1>&2 - done | sort > .version/tmp + test -f ".version/obj/$hash" || cp "$path" ".version/obj/$hash" + done - new="$(sha256sum .version/tmp)" && new="${new%% *}" || exit 1 + new="$(sha256sum .version/tmp | sed 's/ .*//' | tee -a .version/history)" mv -f .version/tmp ".version/rev/$new" + tail -n 2 .version/history + printf '%s\n' "$(uniq .version/history)" > .version/history chmod -w .version/obj/* .version/rev/* - - [ -f .version/history ] && [ "$new" = "$old" ] || - printf '%s\n' "$new" >> .version/history - printf '\nold %s\nnew %s\n' "$old" "$new" }