Skip to content

Commit

Permalink
v 0.95.0
Browse files Browse the repository at this point in the history
Update :
- Add multiple checks before launching update.
- Fetch before updating submodules.
  • Loading branch information
Darklg committed Jun 22, 2024
1 parent 85e1313 commit 3b655c7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
35 changes: 32 additions & 3 deletions bin/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

echo "# UPDATE";

###################################
## Help
###################################

# Help
if [[ "${1}" == 'help' ]];then
echo "Help :";
echo "- '' : Update everything.";
Expand All @@ -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}";
Expand Down Expand Up @@ -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";
Expand Down
1 change: 1 addition & 0 deletions inc/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion wputools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3b655c7

Please sign in to comment.