Skip to content
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
32 changes: 27 additions & 5 deletions src/patch
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,26 @@ for BRANCH in "tatter/scratch" "tatter/patches"; do
done

# Display environment info
echo "************************************"
echo "* CONFIGURATION *"
echo "************************************"
echo ""
echo "Scripts Directory: $SCRIPTS"
echo "Project Directory: $ROOT"
echo "Target Version: $TARGET_VERSION"
echo "Current Version: $SOURCE_VERSION"
echo "Source Package: $PACKAGE"
echo "Base Branch: $BASE"
echo "Selected Items: $ITEMS"
echo ""

# From here on everything is destructive (but reversible) so we want hard stops
set -e

echo "************************************"
echo "* STAGING *"
echo "************************************"
echo ""
# Create a blank branch to work on
git switch --orphan tatter/scratch

Expand All @@ -137,7 +146,7 @@ git clean -fd

# If a current version was requested then change vendor first
if [ "$CURRENT_VERSION" ]; then
composer require "$PACKAGE" "$CURRENT_VERSION"
composer require --no-scripts "$PACKAGE" "$CURRENT_VERSION"
git restore composer.*
fi

Expand All @@ -153,10 +162,10 @@ git commit -m "Stage framework" > /dev/null

# Check for a specific requested version
if [ "$TARGET_VERSION" ]; then
composer require "$PACKAGE" "$TARGET_VERSION"
composer require --no-scripts "$PACKAGE" "$TARGET_VERSION"
# Otherwise get the latest
else
composer update "$PACKAGE"
composer update --no-scripts "$PACKAGE"
fi

# Wipe out the current versions and copy in the new
Expand All @@ -177,14 +186,23 @@ rm composer.*
git switch -c tatter/patches "$BASE"

# Restore the original state of vendor/
composer install > /dev/null
composer install --no-scripts > /dev/null

echo "************************************"
echo "* MERGING *"
echo "************************************"
echo ""

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

if [ $? -eq 0 ]; then
echo "Patch successful! Changes available on branch tatter/patches."
echo "************************************"
echo "* SUCCESS *"
echo "************************************"
echo ""
echo "Patch successful! Updated files are available on branch tatter/patches."
git branch -D tatter/scratch
exit 0
fi
Expand All @@ -193,6 +211,10 @@ git status

# Conflict: explain and exit
echo ""
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."
Expand Down