diff --git a/.envrc b/.envrc index df41b25..64e10c1 100644 --- a/.envrc +++ b/.envrc @@ -15,23 +15,23 @@ now="$(date +%Y-%m-%d)" if [[ ! -d .direnv/tmp ]]; then mkdir -p .direnv/tmp elif command -v find >/dev/null; then - find .direnv/tmp/ -mindepth 1 -maxdepth 1 -type d -and ! -newermt "4 hours ago" -delete + find .direnv/tmp/ -mindepth 1 -maxdepth 1 -type d -and ! -newermt "4 hours ago" -exec rm -rf {} \; fi if [[ ! -s .direnv/pull-date || "$now" != "$(cat .direnv/pull-date)" ]]; then tmp=$(mktemp -p .direnv/tmp -d) trap 'rm -rf "$tmp" >&/dev/null' ERR EXIT RETURN - if ! $GIT diff --exit-code --quiet HEAD -- flake.lock >&/dev/null; then + if ! git diff --exit-code --quiet HEAD -- flake.lock >&/dev/null; then cp flake.lock "$tmp"/dirty-flake.lock - $GIT reset -- flake.lock - $GIT restore -- flake.lock - cp flake.lock "$tmp"/clean-flake.lock # we could instead preserve the current $GIT rev + git reset -- flake.lock + git restore -- flake.lock + cp flake.lock "$tmp"/clean-flake.lock # we could instead preserve the current git rev fi - $GIT pull --rebase --autostash + git pull --rebase --autostash if grep -q "^=======" flake.lock; then # TODO: can this happen anymore? - $GIT reset -- flake.lock + git reset -- flake.lock rm flake.lock # restore? - $GIT checkout -- flake.lock + git checkout -- flake.lock elif [[ -s "$tmp"/clean-flake.lock ]] && ! diff -q "$tmp"/clean-flake.lock flake.lock >&/dev/null; then cp "$tmp"/flake-dirty.lock flake.lock fi