Created
September 8, 2017 14:22
-
-
Save mlutfy/f739677c4bac81b6ec42f4786c7a2d22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Helps apply a CiviCRM github pull-request. | |
# Based on a script by @litespeedmarc | |
if [ $# -ne 1 ] | |
then | |
echo "Invalid syntax. Syntax is $0 <PR> <CRM> <DESC>" | |
fi | |
PATCH_NUMBER=$1 | |
PLATFORMROOT=$2 | |
if [ -z "$PLATFORMROOT" ]; then | |
PLATFORMROOT="/var/aegir/platforms/civicrm-4.7" | |
fi | |
echo "Using platform in $PLATFORMROOT .." | |
echo "Parsing title from PR # $PATCH_NUMBER .." | |
ISSUENUMBER=`curl -s https://api.github.com/repos/civicrm/civicrm-core/issues/10728 | php -r '$t = json_decode(file_get_contents("php://stdin"), TRUE); echo preg_replace("/.*(CRM-\d+).*/", "$1", $t["title"]);'` | |
echo "Patch title is: $ISSUENUMBER .." | |
export PATCH_FILENAME=`date +%Y%m%d`_PR$PATCH_NUMBER_$ISSUENUMBER.patch | |
export PATCH_FILE=$PLATFORMROOT/symbiotic-patches/$PATCH_FILENAME | |
echo "Downloading PR to $PATCH_FILENAME .." | |
curl -s https://patch-diff.githubusercontent.com/raw/civicrm/civicrm-core/pull/$PATCH_NUMBER.patch > $PATCH_FILE | |
echo "Testing whether the patch can be applied .." | |
cd $PLATFORMROOT | |
git apply --check --verbose --directory sites/all/modules/civicrm/ $PATCH_FILE | |
echo "" | |
echo "You can now apply the patch using this command: " | |
echo "First to check: " | |
echo git apply --verbose --directory sites/all/modules/civicrm/ --check $PATCH_FILE | |
echo "" | |
echo "Then to apply:" | |
echo git apply --verbose --directory sites/all/modules/civicrm/ $PATCH_FILE | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment