diff --git a/.gitmodules b/.gitmodules index d07aaf6..fcba508 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "DEV1.1/TP"] path = DEV1.1/TP url = gitea@grond.iut-fbleau.fr:vincentg/DEV.git + branch = main diff --git a/DEV1.1/TP b/DEV1.1/TP index b99aa03..70a3078 160000 --- a/DEV1.1/TP +++ b/DEV1.1/TP @@ -1 +1 @@ -Subproject commit b99aa0392b77052ce1eacf454a54f071e62b8a52 +Subproject commit 70a30784287a3c84805bb0dddd6a631e73ccac90 diff --git a/update.sh b/update.sh index e03237a..96061c4 100755 --- a/update.sh +++ b/update.sh @@ -1,33 +1,50 @@ #!/bin/sh # Set PATH so cron can find git, date, ssh, etc. -export PATH="/usr/local/bin:/usr/bin:/bin:$PATH" +export PATH="/usr/local/bin:/usr/bin:/bin" # Explicitly set target directory (don't rely on $HOME in cron) TARGET_DIR="/home/benji/Documents/COURS" +# SSH key pour Git (appliquée à la fois à Homelab et IUT) +export GIT_SSH_COMMAND="ssh -i /home/benji/.ssh/git -o IdentitiesOnly=yes" + # Navigate to target directory cd "$TARGET_DIR" || { echo "Directory not found" exit 1 } -# Pull remote changes rebase-style +# 1. Pull remote changes (repo principal + sous-modules) git pull --rebase --autostash || { - echo "Git pull failed" + echo "Git pull failed on COURS" + exit 1 +} +git submodule update --remote --merge || { + echo "Git submodule update failed" exit 1 } -# Stage all files +# 2. Traitement du sous-module TP (Gitea IUT) +if [ -d "DEV1.1/TP" ]; then + cd DEV1.1/TP + git add -A + if ! git diff-index --quiet HEAD --; then + git commit -m "sync: $(date +'%Y-%m-%d %H:%M')" + git push || echo "Avertissement : Git push à échoué sur le sous-module TP" + fi + cd "$TARGET_DIR" || exit 1 +fi + +# 3. Traitement du dépôt principal COURS (Gitea Homelab) 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" + echo "Git push failed on COURS" exit 1 } else - echo "No changes to commit." + echo "No changes to commit in COURS." fi