improve conflink outdated detection
authorIan Kelling <ian@iankelling.org>
Sat, 19 Oct 2019 16:04:25 +0000 (12:04 -0400)
committerIan Kelling <ian@iankelling.org>
Sat, 19 Oct 2019 16:04:25 +0000 (12:04 -0400)
conflink
system-status

index a763c22a03eb2d29db832a3eed473d322d4e9b11..42c811a6437f16b9e195b1fded71eb3516826efe 100755 (executable)
--- a/conflink
+++ b/conflink
@@ -149,4 +149,8 @@ case $user in
     ;;
 esac
 
+f=/a/bin/distro-setup/system-status
+if [[ -x $f ]]; then
+  $f _
+fi
 echo 0 >~/.local/conflink
index e137d06f3b4b15c44b884e6dc04e8eb17d0a3759..d6db7c3eb57b351c01b97c627376f55ad424e33f 100755 (executable)
@@ -13,6 +13,15 @@ status_file=/dev/shm/iank-status
 shopt -s nullglob
 shopt -s dotglob
 
+verbose=false
+if [[ $1 ]]; then
+  verbose=true
+fi
+v() {
+  if $verbose; then
+    printf "%s\n" "$*"
+  fi
+}
 lo() { /usr/local/bin/log-once "$@"; }
 
 write-status() {
@@ -51,26 +60,48 @@ write-status() {
   fi
 
   f=~/.local/conflink
-  if [[ -e $f ]]; then
-    now=$(date +%s)
-    fsec=$(stat -c%Y $f)
-    fmin=$(( (fsec - now ) / 60 + 1 ))
-    fminplus=$(( fmin + 60*24 ))
-    # Filesystem files get copied, so find any newer than the last run.
-    # The rest are hueristics:
-    # Given the last time we added a file in git, is that newer than the last conflink run.
-    # Given new files not added to git, were they modified more recently than the last conflink? but,
-    # push their modification time back by a day so we can develop them before needing to add them to git.
-    if (( $(date -d "$(git log --diff-filter=ACR --format=%aD -1)" +%s) > fsec )) || \
-         [[ $(find {/a/bin/ds,/p/c}{/filesystem,/machine_specific/$HOSTNAME/filesystem} -mmin $fmin -type f -print -quit 2>/dev/null) ]] \
-         || [[ $(find $(git ls-files -o --exclude-standard) -mmin $fminplus -type f -print -quit) ]]; then
+  for _ in 1; do
+    if [[ -e $f ]]; then
+      now=$(date +%s)
+      fsec=$(stat -c%Y $f)
+      fmin=$(( (fsec - now ) / 60 + 1 ))
+      fminplus=$(( fmin + 60*24 ))
+      # Filesystem files get copied, so find any newer than the last run.
+      # The rest are hueristics:
+      # Given the last time we added a file in git, is that newer than the last conflink run.
+      # Given new files not added to git, were they modified more recently than the last conflink? but,
+      # push their modification time back by a day so we can develop them before needing to add them to git.
+
+      all_dirs=({/a/bin/ds,/p/c}{/filesystem,/machine_specific/$HOSTNAME/filesystem})
+      # This part is copied from conflink
+      for x in /p/c/machine_specific/*.hosts /a/bin/ds/machine_specific/*.hosts; do
+        if grep -qxF $HOSTNAME $x; then all_dirs+=( ${x%.hosts} ); fi
+      done
+
+      if (( $(date -d "$(git log --diff-filter=ACR --format=%aD -1)" +%s) > fsec )) || \
+           [[ $(find ${all_dirs[@]} -mmin $fmin -type f -print -quit 2>/dev/null) ]]; then
+        v conflink newer git or newer filesystem files
+        chars+=("CONFLINK!")
+        break
+      fi
+
+      for d in /a/bin/distro-setup /p/c; do
+        cd $d
+        untracked=$(git ls-files -o --exclude-standard)
+        if [[ $untracked && $(find $untracked -mmin $fminplus -type f -print -quit) ]]; then
+          v conflink: untracked in $d
+          chars+=("CONFLINK!")
+          break
+        fi
+      done
+
+    fi
+    if [[ ! -e $f || $(<$f) != 0 ]]; then
+      v conflink: last run not found or failed
       chars+=("CONFLINK!")
+      break
     fi
-  fi
-
-  if [[ ! -e $f || $(<$f) != 0 ]]; then
-    chars+=("CONFLINK!")
-  fi
+  done
 
 
   ## Clean the paniclog, but only up to 4 times per day, or else we