Skip to content
Snippets Groups Projects
Commit 30592df1 authored by daffie's avatar daffie
Browse files

Issue #3503067 by daffie: Create script to create Drupal core patch

parent 29a313fa
Branches
Tags 3.0.0
1 merge request!36Added script to generate a Drupal core patch from the PR from the Drupal core issue
Pipeline #409272 failed
#!/bin/bash
# This script is to generate a Drupal core patch from the PR for the full support issue.
# The expected first parameter is the file name of the downloaded PR.
# The expected second parameter is the version for which to create the patch file.
if [[ -z $1 ]];
then
echo "The patch file to generate the Drupal core patch file for must be given as the first parameter"
exit 1;
fi
if [[ ! -f $1 ]];
then
echo "The patch file to generate the Drupal core patch file for does not exist."
exit 1;
fi
if [[ -z $2 ]];
then
echo "The patch file to generate the Drupal core patch file for must be given a version as the second parameter"
exit 1;
fi
echo 'Start generating Drupal core patch file...'
# Get the current directory to copy the created patch file to.
currentdir=$(pwd)
# Create a temporary directory.
tempdir=$(mktemp -d)
# Copy the base PR file to the temporary directory.
cp $1 $tempdir
# Make the temporary directory the current working directory
cd $tempdir
if [[ ! -f $1 ]];
then
echo "The patch file to generate the Drupal core patch file for does not exist in the temporary directory: '$tempdir'."
exit 1;
fi
# Split the base PR file into single file with one for every file change.
splitdiff -ad $1 > /dev/null 2>&1
# Remove all the test files.
find . -name '*Test.php.patch' | xargs rm -f
find . -name '*tests*' | xargs rm -f
find . -name '*Test*' | xargs rm -f
# Remove all the mongodb module files.
find . -name '*core_modules_mongodb*' | xargs rm -f
# Remove the composer changes.
find . -name '*composer*' | xargs rm -f
# Remove the GitLab pipeline file changes.
find . -name '*gitlab*' | xargs rm -f
# Remove the PHPStan baseline file changes.
find . -name '*phpstan-baseline*' | xargs rm -f
# Remove the CSpell file changes.
find . -name '*cspell*' | xargs rm -f
#find . -name '*migrate_source*' | xargs rm -f
# Get the number of file changes.
count=$(ls -1 | wc -l)
printf "%s\n" 'The Drupal core patch has '$count' file changes'
combined='drupal-core-'$2
touch $combined'.diff'
# Create the Drupal core patch file.
cat *.patch >> $combined'.diff'
# Copy the created Drupal core patch file to the current directory.
cp $combined'.diff' $currentdir/$combined'.patch'
echo "Finished! The Drupal core patch file is: '$combined.patch'"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment