From 3ab9d127437623c64c0ff1f95fcb6ffb6a291eeb Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Sun, 10 Nov 2024 00:55:29 -0500 Subject: [PATCH] AutoYADM commit: 2024-11-10 00:55:29 --- .config/yadm/autoyadm.sh | 25 ++++++++++++++++++------- .config/yadm/config | 2 ++ .config/yadm/testingfile | 0 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .config/yadm/testingfile diff --git a/.config/yadm/autoyadm.sh b/.config/yadm/autoyadm.sh index 84ce95c1..418336ea 100755 --- a/.config/yadm/autoyadm.sh +++ b/.config/yadm/autoyadm.sh @@ -7,12 +7,22 @@ AYE="AutoYADM Error:" AYM="AutoYADM:" + +# We check not to overwrite the user's env setting +if [ -z "$VAR" ]; then + AUTOYADMPUSH=0 +fi + # Set hostname explicitly because it # may not be present in this shell environment -HOST="$(hostname)" +if [ -z "$HOST" ]; then + HOST="$(hostname)" +fi # First we read each path from "tracked" -while read -r path; do +(while read -r path; do + # we disable ignored warning for this subshell + yadm config advice.addIgnoredFile false # Execute yadm add on each real file # if the path points to a directory # This ensures symlinks are not added @@ -26,22 +36,23 @@ while read -r path; do echo "$AYE Target must be a directory or a file!" exit 1 fi -done <"$HOME/.config/yadm/tracked" +done) <"$HOME/.config/yadm/tracked" # Define the location of the ssh-agent environment sshenv="$HOME/.ssh/environment-$HOST" - if [[ -n $(yadm status --porcelain) ]]; then yadm commit -m "AutoYADM commit: $(date +'%Y-%m-%d %H:%M:%S')" # Check if the ssh-agent env exists - if [ -f "$sshenv" ]; then + if [[ -f "$sshenv" ]]; then + if ((!AUTOYADMPUSH)); then + echo "$AYM Pushing disabled, aborting..." + exit 1 + fi # Directive to suppress shellcheck warning # shellcheck source=/dev/null source "$sshenv" yadm push else - echo "Host value is: '$HOST'" - echo "Expected SSH env file path: $sshenv" echo "$AYE ssh-agent environment not found, aborting push..." exit 1 fi diff --git a/.config/yadm/config b/.config/yadm/config index ca0288c7..42500c2e 100644 --- a/.config/yadm/config +++ b/.config/yadm/config @@ -1,2 +1,4 @@ [pull] rebase = false +[advice] + addIgnoredFile = false diff --git a/.config/yadm/testingfile b/.config/yadm/testingfile new file mode 100644 index 00000000..e69de29b