From ed7f4974034644b154221813fd9309fa2fdcc5ab Mon Sep 17 00:00:00 2001 From: Jali Date: Sun, 21 Sep 2025 02:33:24 +0200 Subject: [PATCH] Add a fetch step to make sure the script is on par with the git server --- services/git-monitor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/git-monitor b/services/git-monitor index 6a9ca88..99c414b 100755 --- a/services/git-monitor +++ b/services/git-monitor @@ -63,11 +63,12 @@ check_for_updates() { fi # Fetch the latest commit hash from the remote repository - current_commit_hash=$(git -C "$REPO_LOCAL_PATH/$repo_name" rev-parse HEAD) + git -C "$REPO_LOCAL_PATH/$repo_name" fetch origin $BRANCH_NAME + current_commit_hash=$(git -C "$REPO_LOCAL_PATH/$repo_name" origin $BRANCH_NAME) if [ -z "$last_commit_hash" ] || [ "$current_commit_hash" != "$last_commit_hash" ]; then log_message "INFO" "New commits detected. Pulling..." - git -C "$REPO_LOCAL_PATH/$repo_name" pull origin "$BRANCH_NAME" + git -C "$REPO_LOCAL_PATH/$repo_name" checkout origin "$BRANCH_NAME" if [ $? -eq 0 ]; then log_message "INFO" "Pull successful."