Modified update process to update only changed files

This commit is contained in:
CosmicScale 2025-02-23 19:47:42 +00:00
parent ba4d1597c8
commit 04ca4400ff
3 changed files with 64 additions and 21 deletions

View File

@ -28,13 +28,28 @@ else
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date."
else
echo "Downloading update..."
git reset --hard && git pull --force > /dev/null 2>&1
echo
echo "The script has been updated to the latest version."
read -n 1 -s -r -p "Press any key to exit, then run the script again."
echo
exit 0
echo "Downloading updates..."
# Get a list of files that have changed remotely
UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE")
if [ -n "$UPDATED_FILES" ]; then
echo "Files updated in the remote repository:"
echo "$UPDATED_FILES"
# Reset only the files that were updated remotely (discard local changes to them)
echo "$UPDATED_FILES" | xargs git checkout --
# Pull the latest changes
git pull --ff-only
echo
echo "The script has been updated to the latest version."
read -n 1 -s -r -p "Press any key to exit, then run the script again."
echo
exit 0
else
echo "The repository is up to date."
fi
fi
fi

View File

@ -39,13 +39,27 @@ else
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." | tee -a "${INSTALL_LOG}"
else
echo "Downloading update..."
git reset --hard && git pull --force >> "${INSTALL_LOG}" 2>&1
echo
echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}"
read -n 1 -s -r -p "Press any key to exit, then run the script again."
echo
exit 0
echo "Downloading updates..."
# Get a list of files that have changed remotely
UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE")
if [ -n "$UPDATED_FILES" ]; then
echo "Files updated in the remote repository:" | tee -a "${INSTALL_LOG}"
echo "$UPDATED_FILES" | tee -a "${INSTALL_LOG}"
# Reset only the files that were updated remotely (discard local changes to them)
echo "$UPDATED_FILES" | xargs git checkout -- >> "${INSTALL_LOG}" 2>&1
# Pull the latest changes
git pull --ff-only >> "${INSTALL_LOG}" 2>&1
echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}"
read -n 1 -s -r -p "Press any key to exit, then run the script again."
echo
exit 0
else
echo "The repository is up to date." | tee -a "${INSTALL_LOG}"
fi
fi
fi

View File

@ -64,13 +64,27 @@ else
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." | tee -a "${LOG_FILE}"
else
echo "Downloading update..."
git reset --hard && git pull --force >> "${LOG_FILE}" 2>&1
echo
echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit, set your custom game path if needed, and then run the script again."
echo
exit 0
echo "Downloading updates..."
# Get a list of files that have changed remotely
UPDATED_FILES=$(git diff --name-only "$LOCAL" "$REMOTE")
if [ -n "$UPDATED_FILES" ]; then
echo "Files updated in the remote repository:" | tee -a "${LOG_FILE}"
echo "$UPDATED_FILES" | tee -a "${LOG_FILE}"
# Reset only the files that were updated remotely (discard local changes to them)
echo "$UPDATED_FILES" | xargs git checkout -- >> "${LOG_FILE}" 2>&1
# Pull the latest changes
git pull --ff-only >> "${LOG_FILE}" 2>&1
echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}"
read -n 1 -s -r -p "Press any key to exit, set your custom game path if needed, and then run the script again."
echo
exit 0
else
echo "The repository is up to date." | tee -a "${LOG_FILE}"
fi
fi
fi