From 385a84ee22420e34dfa53cd3fb3ef78dbf0be933 Mon Sep 17 00:00:00 2001 From: Benji Date: Tue, 1 Sep 2026 21:33:35 +0200 Subject: [PATCH] sync: 2026-09-01 21:33 --- grab.sh | 8 -------- update.sh | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) delete mode 100755 grab.sh diff --git a/grab.sh b/grab.sh deleted file mode 100755 index 549f568..0000000 --- a/grab.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -cd /home/benji/Documents/COURS || exit - -git fetch -git pull - - diff --git a/update.sh b/update.sh index 326ce8c..c3937f7 100755 --- a/update.sh +++ b/update.sh @@ -1,9 +1,20 @@ #!/bin/sh -cd /home/benji/Documents/COURS || exit +TARGET_DIR="$HOME/Documents/COURS" -./grab.sh +# Navigate to target directory +cd "$TARGET_DIR" || { echo "Directory not found"; exit 1; } -git add . -git commit -m "$(date +'%d/%m')" -git push +# Pull remote changes rebase-style to prevent messy merge commits +git pull --rebase --autostash || { echo "Git pull failed"; exit 1; } + +# Stage all files +git add -A + +# Commit only if there are actual changes staged +if ! git diff-index --quiet HEAD --; then + git commit -m "sync: $(date +'%Y-%m-%d %H:%M')" + git push || { echo "Git push failed"; exit 1; } +else + echo "No changes to commit." +fi