aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2024-02-18 21:59:05 -0600
committerToby Vincent <tobyv@tobyvin.dev>2024-02-18 22:00:35 -0600
commit61147370caac0cf4c03d7a15ea633caa39b4376f (patch)
tree5799eda57eba595a5aaa73af071ca64174a4fed8
parent850cc1dfa080091664f5f0dee2bcdc129b58b983 (diff)
build: add time/commit check for install scripts
-rw-r--r--.gitignore1
-rwxr-xr-xinstall.sh11
-rwxr-xr-xnvim/install.sh4
-rwxr-xr-xpass/install.sh4
4 files changed, 17 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 05e891e..3f7160d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
!/*/**
+.installed
.untracked
diff --git a/install.sh b/install.sh
index 4b99be9..2786499 100755
--- a/install.sh
+++ b/install.sh
@@ -1,13 +1,18 @@
#!/bin/sh
-# shellcheck disable=SC2035
+# shellcheck disable=SC2035,SC2086
set -e
CDPATH='' cd -- "$(dirname -- "$0")" || exit
+if [ -r .installed ]; then
+ read -r DOTFILES_INSTALLED <.installed
+ export DOTFILES_INSTALLED
+fi
+
printf "%s: Removing bad links\n" "$0"
{
- git log --name-only --no-renames --diff-filter=D --format=format:
+ git log --name-only --no-renames --diff-filter=D --format=format: $DOTFILES_INSTALLED HEAD
git diff --name-only --no-renames --diff-filter=D HEAD
if [ -f .untracked ]; then
cat .untracked
@@ -30,3 +35,5 @@ printf "%s: Installing packages\n" "$0"
for f in ${1:-*}/install.sh; do
$f
done
+
+git rev-parse ^@ >.installed
diff --git a/nvim/install.sh b/nvim/install.sh
index 556e188..72c3f39 100755
--- a/nvim/install.sh
+++ b/nvim/install.sh
@@ -7,6 +7,10 @@ if ! command -v "$pkgname" >/dev/null; then
exit 0
fi
+if test .installed -nt $pkgname; then
+ exit 0
+fi
+
printf "%s: Installing plugins\n" "$0"
nvim --headless -c 'Lazy! restore' -c qa
diff --git a/pass/install.sh b/pass/install.sh
index f91caf4..54d1b8d 100755
--- a/pass/install.sh
+++ b/pass/install.sh
@@ -16,7 +16,9 @@ if [ ! -d "$store" ]; then
else
printf "%s: Syncing password-store\n" "$0"
- git -C "$store" remote update origin
+ if [ "$(date "+%s" -r "$store"/.git/FETCH_HEAD)" -lt "$(date +%s --date="12 hour ago")" ]; then
+ git -C "$store" remote update origin
+ fi
LOCAL=$(git -C "$store" rev-parse @)
REMOTE=$(git -C "$store" rev-parse '@{u}')