Skip to content

feat: colored output #41

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
31 changes: 21 additions & 10 deletions src/patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ Examples:
EOT
}

# Color definitions
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
RESET='\033[0m'

CURRENT_VERSION=""
TARGET_VERSION=""

Expand Down Expand Up @@ -131,10 +140,10 @@ for BRANCH in "tatter/scratch" "tatter/patches"; do
done

# Display environment info
echo "************************************"
echo "${GREEN}************************************"
echo "* CONFIGURATION *"
echo "************************************"
echo ""
echo "${RESET}"
echo "Scripts Directory: $SCRIPTS"
echo "Project Directory: $ROOT"
echo "Target Version: $TARGET_VERSION"
Expand All @@ -147,10 +156,11 @@ echo ""
# From here on everything is destructive (but reversible) so we want hard stops
set -e

echo "************************************"
echo "${GREEN}************************************"
echo "* STAGING *"
echo "************************************"
echo ""
echo "${RESET}"

# Create a blank branch to work on
git checkout --orphan tatter/scratch
git rm -rf .
Expand Down Expand Up @@ -202,6 +212,7 @@ done
# Add everything but the modified Composer files
git add .
git reset composer.*
echo "${GREEN}> git commit -m \"Patch framework $FROMTO\" --no-verify${RESET}"
git commit -m "Patch framework $FROMTO" --no-verify

# Get rid of the now-corrupt Composer files
Expand All @@ -213,36 +224,36 @@ git checkout -b tatter/patches "$BASE"
# Restore the original state of vendor/
composer install --no-scripts > /dev/null

echo "************************************"
echo "${GREEN}************************************"
echo "* MERGING *"
echo "************************************"
echo ""
echo "${RESET}"

# Attempt the merge
set +e
git cherry-pick tatter/scratch

if [ $? -eq 0 ]; then
echo "************************************"
echo "${GREEN}************************************"
echo "* SUCCESS *"
echo "************************************"
echo ""
echo "Patch successful! Updated files are available on branch tatter/patches."
echo "Patch successful! Updated files are available on branch tatter/patches.${RESET}"
git branch -D tatter/scratch
exit 0
fi

git status

# Conflict: explain and exit
echo ""
echo "${RED}"
echo "************************************"
echo "* RESOLUTION *"
echo "************************************"
echo ""
echo "Conflicts detected during patch! Follow the git instructions for resolution."
echo "Once resolution is complete your changes will be available on branch tatter/patches"
echo "and you should remove the old working branch at tatter/scratch."
echo ""
echo "${RESET}"

exit 1