Skip to content

Fix error when no file to add or remove on release #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 52 additions & 7 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,45 @@
#TODO: svn checkout, svn commit (if needed) after svn sync
QUIET=1
SYNC_SVN=0
# Read PATH_TO_COMPOSER from env if provided, otherwise use default
[ -z "$PATH_TO_COMPOSER" ] && PATH_TO_COMPOSER="/usr/bin/php5.6 /usr/local/bin/composer "
# Define the path to Composer and PHP
PHP_PATH=$(which php 2>/dev/null)
COMPOSER_PATH=$(which composer 2>/dev/null)
if [ ! -x "$PHP_PATH" ]; then
echo "Can't find or execute PHP on: $PHP_PATH"
exit 1
fi

# Get PHP version
PHP_VERSION=$($PHP_PATH -v | head -n 1 | awk '{print $2}')
PHP_MAJOR=$(echo "$PHP_VERSION" | cut -d. -f1) # Extract major version
PHP_MINOR=$(echo "$PHP_VERSION" | cut -d. -f2) # Extract minor version

# Check if PHP version is exactly 5.6.x
if [[ "$PHP_MAJOR" -eq 5 && "$PHP_MINOR" -eq 6 ]]; then
echo "PHP version is $PHP_VERSION (compatible)."
else
echo "PHP version is $PHP_VERSION. Only PHP 5.6.x is supported."
exit 1
fi

if [ ! -x "$COMPOSER_PATH" ]; then
echo "Can't find or execute Composer on : $PHP_PATH $COMPOSER_PATH"
exit 1
fi

# Get Composer version
COMPOSER_VERSION=$($COMPOSER_PATH --version | awk '{print $3}' | cut -d. -f1,2) # Extract major.minor version

# Check if Composer version is exactly 2.2.x
if [[ "$COMPOSER_VERSION" == "2.2" ]]; then
echo "Composer version is $COMPOSER_VERSION (compatible)."
else
echo "Composer version is $COMPOSER_VERSION. Only Composer 2.2.x (LTS) is supported."
exit 1
fi

PATH_TO_COMPOSER="$PHP_PATH $COMPOSER_PATH"
echo "PATH_TO_COMPOSER is: $PATH_TO_COMPOSER"

# {{{ function usage
#
Expand Down Expand Up @@ -133,7 +170,7 @@ syncing_subversion() {
if [[ ! -d "$SUBVERSION_DIR" ]] ; then
trap - ERR EXIT
is_that_ok 1
echo "'$SUBVERSION_DIR': Subversion's folder not found !!!"
echo "'$SUBVERSION_DIR': Subversion's folder not found!"
echo "Please clone subversion repository with valid wordpress credentials (\`svn checkout https://plugins.svn.wordpress.org/alma-gateway-for-woocommerce $SUBVERSION_DIR\`)"
exit 1
fi
Expand All @@ -144,10 +181,18 @@ syncing_subversion() {
rm -rf $SUBVERSION_DIR/assets/*
rsync -au $RSYNC_EXCLUDE $HERE/.wordpress.org/ ./assets >/dev/null 2>&1
svn cp trunk tags/$VERSION
svn add $(svn status | awk '$1 ~ /\?/ {print $2}') \
|| quit "Error occurs while adding subversion new files"
svn rm $(svn status | awk '$1 ~ /\!/ {print $2}') \
|| quit "Error occurs while removing subversion deleted files"
files=$(svn status | awk '$1 ~ /\?/ {print $2}')
if [ -n "$files" ]; then
svn add $files || quit "Error occurs while adding subversion new files"
else
echo "No new files to add."
fi
files=$(svn status | awk '$1 ~ /\!/ {print $2}')
if [ -n "$files" ]; then
svn rm $files || quit "Error occurs while removing subversion files"
else
echo "No files to delete."
fi
cd -
}
export -f syncing_subversion
Expand Down
Loading