Skip update check gracefully if not a Git repository

This commit is contained in:
CosmicScale 2025-01-28 16:42:42 +00:00
parent 4b6b97205e
commit 7d295eb836
3 changed files with 64 additions and 49 deletions

View File

@ -13,23 +13,28 @@ if [[ ! -f "${TOOLKIT_PATH}/helper/PFS Shell.elf" || ! -f "${TOOLKIT_PATH}/helpe
exit 1 exit 1
fi fi
# Fetch updates from the remote # Check if the current directory is a Git repository
git fetch > /dev/null 2>&1 if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "This is not a Git repository. Skipping update check."
# Check the current status of the repository
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date."
else else
echo "Downloading update..." # Fetch updates from the remote
git reset --hard && git pull --force > /dev/null 2>&1 git fetch > /dev/null 2>&1
echo
echo "The script has been updated to the latest version." # Check the current status of the repository
read -p "Press any key to exit, then run the script again." LOCAL=$(git rev-parse @)
exit 0 REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
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 -p "Press any key to exit, then run the script again."
exit 0
fi
fi fi
echo " _____ _ "; echo " _____ _ ";

View File

@ -18,29 +18,34 @@ if [[ ! -f "${TOOLKIT_PATH}/helper/PFS Shell.elf" || ! -f "${TOOLKIT_PATH}/helpe
exit 1 exit 1
fi fi
echo "####################################################################">> "${INSTALL_LOG}"; echo "########################################################################################################">> "${INSTALL_LOG}";
date >> "${INSTALL_LOG}" date >> "${INSTALL_LOG}"
echo >> "${INSTALL_LOG}" echo >> "${INSTALL_LOG}"
echo "Path set to: $TOOLKIT_PATH" >> "${INSTALL_LOG}" echo "Path set to: $TOOLKIT_PATH" >> "${INSTALL_LOG}"
echo "Helper files found." >> "${INSTALL_LOG}" echo "Helper files found." >> "${INSTALL_LOG}"
# Fetch updates from the remote # Check if the current directory is a Git repository
git fetch >> "${INSTALL_LOG}" 2>&1 if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "This is not a Git repository. Skipping update check." >> "${INSTALL_LOG}"
# Check the current status of the repository
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." >> "${INSTALL_LOG}"
else else
echo "Downloading update..." # Fetch updates from the remote
git reset --hard && git pull --force >> "${INSTALL_LOG}" 2>&1 git fetch >> "${INSTALL_LOG}" 2>&1
echo
echo "The script has been updated to the latest version." | tee -a "${INSTALL_LOG}" # Check the current status of the repository
read -p "Press any key to exit, then run the script again." LOCAL=$(git rev-parse @)
exit 0 REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." >> "${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 -p "Press any key to exit, then run the script again."
exit 0
fi
fi fi
# Choose the PS2 storage device # Choose the PS2 storage device

View File

@ -36,23 +36,28 @@ echo >> "${LOG_FILE}"
echo "Path set to: $TOOLKIT_PATH" >> "${LOG_FILE}" echo "Path set to: $TOOLKIT_PATH" >> "${LOG_FILE}"
echo "Helper files found." >> "${LOG_FILE}" echo "Helper files found." >> "${LOG_FILE}"
# Fetch updates from the remote # Check if the current directory is a Git repository
git fetch >> "${LOG_FILE}" 2>&1 if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo "This is not a Git repository. Skipping update check." >> "${LOG_FILE}"
# Check the current status of the repository
LOCAL=$(git rev-parse @)
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." >> "${LOG_FILE}"
else else
echo "Downloading update..." # Fetch updates from the remote
git reset --hard && git pull --force >> "${LOG_FILE}" 2>&1 git fetch >> "${LOG_FILE}" 2>&1
echo
echo "The script has been updated to the latest version." | tee -a "${LOG_FILE}" # Check the current status of the repository
read -p "Press any key to exit, set your custom game path if needed, and then run the script again." LOCAL=$(git rev-parse @)
exit 0 REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @ @{u})
if [ "$LOCAL" = "$REMOTE" ]; then
echo "The repository is up to date." >> "${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 -p "Press any key to exit, set your custom game path if needed, and then run the script again."
exit 0
fi
fi fi
function clean_up() { function clean_up() {