diff --git a/bin/update.sh b/bin/update.sh index e017920..25c360a 100644 --- a/bin/update.sh +++ b/bin/update.sh @@ -2,8 +2,10 @@ echo "# UPDATE"; +################################### +## Help +################################### -# Help if [[ "${1}" == 'help' ]];then echo "Help :"; echo "- '' : Update everything."; @@ -17,12 +19,39 @@ if [[ "${1}" == 'help' ]];then return; fi; -# Check lock +################################### +## Checks before launching update +################################### + +# Check if git is locked if [[ -f "${_CURRENT_DIR}.git/index.lock" ]];then bashutilities_message "Error : Git repository is locked" 'error'; return; fi; +# Check if there are uncommited changes +if [[ $(git status --porcelain) ]]; then + bashutilities_message "Error : There are uncommited changes" 'error'; + return; +fi; + +# Check if there are unpushed commits +if [[ $(git log origin/$(git symbolic-ref --short HEAD)..HEAD) ]]; then + bashutilities_message "Error : There are unpushed commits" 'error'; + return; +fi; + +# Check if WP env is not in production +_WP_PROJECT_ENV=$(_WPCLICOMMAND config get WP_ENVIRONMENT_TYPE); +if [[ "${_WP_PROJECT_ENV}" == 'production' || "${_WP_PROJECT_ENV}" == 'prod' ]];then + bashutilities_message "Error : You can't update in production" 'error'; + return; +fi; + +################################### +## Variables +################################### + _ADMIN_PROTECT_FILE=$(find . -mount -name 'wputh_admin_protect.php'); _ADMIN_PROTECT_FLAG=".disable_wpu_admin_protect"; _ADMIN_PROTECT_FLAG_FILE="${_CURRENT_DIR}${_ADMIN_PROTECT_FLAG}"; @@ -260,7 +289,7 @@ function wputools__update_all_plugins() { function wputools__update_all_submodules() { echo '# Updating submodules'; - git submodule foreach 'git checkout master; git checkout main; git pull origin'; + git submodule foreach 'git fetch; git checkout master; git checkout main; git pull origin'; # Update commit_without_protect "Update Submodules"; diff --git a/inc/stop.sh b/inc/stop.sh index e842a2e..26bc8a7 100644 --- a/inc/stop.sh +++ b/inc/stop.sh @@ -98,6 +98,7 @@ unset -v _STATIC_RAND; unset -v _tmp_dump; unset -v _tmp_folder; unset -v _TMPLINE; +unset -v _WP_PROJECT_ENV; unset -v _WPDB_BACKUP_LOCAL_DIR; unset -v _WPDB_REPLACE_AFTER; unset -v _WPDB_REPLACE_BEFORE; diff --git a/wputools.sh b/wputools.sh index 5397632..ec1e8b5 100644 --- a/wputools.sh +++ b/wputools.sh @@ -2,7 +2,7 @@ WPUTools(){ -local _WPUTOOLS_VERSION='0.94.1'; +local _WPUTOOLS_VERSION='0.95.0'; local _PHP_VERSIONS=(7.0 7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3 8.4 8.5 9.0) local _PHP_VERSIONS_OBSOLETES=(7.0 7.1 7.2 7.3 7.4) local _PHP_VERSIONS_ADVANCED=(8.2 8.3 8.4 8.5 9.0)