Changeset 1207
- Timestamp:
- 01/30/2015 01:05:23 AM (10 years ago)
- Location:
- sites/trunk/api.wordpress.org/public_html/dotorg/github-sync
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/dotorg/github-sync/feature-plugins.php
r1185 r1207 5 5 6 6 require dirname( dirname( __DIR__ ) ) . '/init.php'; 7 require WPORGPATH . '/.config/secrets.php';8 7 9 8 class GH2WORG { … … 12 11 // Github User/Repo => plugins.svn.wordpress.org/****/trunk/ 13 12 'dd32/feature-plugin-testing' => 'test-plugin-3', 13 'MichaelArestad/Press-This' => 'press-this', 14 14 ); 15 15 … … 48 48 list( $algo, $hash ) = explode( '=', $_SERVER['HTTP_X_HUB_SIGNATURE'], 2 ); 49 49 50 // Todo? Doesn't handle standard $_POST 50 // Todo? Doesn't handle standard $_POST, only application/json 51 51 $hmac = hash_hmac( $algo, file_get_contents('php://input' ), FEATURE_PLUGIN_GH_SYNC_SECRET ); 52 52 … … 63 63 putenv( 'PHP_SVN_PASSWORD=' . FEATURE_PLUGIN_GH_SYNC_PASS ); 64 64 65 $result = shell_exec( __DIR__ . "/feature-plugins.sh $github_url $svn_directory 2>&1" ); 66 67 echo preg_replace( '!/tmp/[^ ]+-([^-/ ]+/?)!i', '~/$1', $result ); 65 echo shell_exec( __DIR__ . "/feature-plugins.sh $github_url $svn_directory 2>&1" ); 68 66 69 67 putenv( 'PHP_SVN_USER' ); -
sites/trunk/api.wordpress.org/public_html/dotorg/github-sync/feature-plugins.sh
r1185 r1207 3 3 GITHUB_URL=$1; 4 4 SVN_PLUGIN=$2; 5 6 # Split by newlines only in bash arrays 7 IFS=$'\r\n' 5 8 6 9 # ENV vars: $PHP_SVN_USER, $PHP_SVN_PASSWORD … … 11 14 12 15 SVN_URL="https://plugins.svn.wordpress.org/$SVN_PLUGIN/trunk/" 16 ASSETS_SVN_URL="https://plugins.svn.wordpress.org/$SVN_PLUGIN/assets/" 13 17 14 18 WORKING_DIR=$(mktemp -d /tmp/gh-plugin-sync-XXXXXXX) 19 ASSETS_WORKING_DIR=$(mktemp -d /tmp/gh-plugin-assets-XXXXXXX) 15 20 COMMIT_MESSAGE=$(mktemp /tmp/gh-plugin-sync-commit-XXXXXX) 16 21 function finish { 17 22 rm -rf "$WORKING_DIR" 18 23 rm -rf "$COMMIT_MESSAGE" 19 echo Script Done. 24 rm -rf "$ASSETS_WORKING_DIR" 25 echo Sync Done. 20 26 } 21 27 trap finish EXIT … … 23 29 cd $WORKING_DIR 24 30 25 echo $(uname -n | sed 's/.wordpress.org$//')Merging from $GITHUB_URL to $SVN_URL31 echo Merging from $GITHUB_URL to $SVN_URL 26 32 27 33 # Checkout 28 svn co --non-interactive --force $SVN_URL $WORKING_DIR 2>&134 svn co --non-interactive --force -q $SVN_URL $WORKING_DIR 2>&1 29 35 30 36 # Get the last GIT Rev sync … … 50 56 if [ $LAST_GIT_SYNC_REV ]; then 51 57 # Get the Commit messages 52 echo Syncing $GITHUB_URL to $SVN_URL > $COMMIT_MESSAGE 53 git log $LAST_GIT_SYNC_REV..$LATEST_GIT_REV | tee $COMMIT_MESSAGE 58 GIT_LOG=$( git log $LAST_GIT_SYNC_REV..$LATEST_GIT_REV ) 59 60 # Split the Git Commit logs up 61 GIT_LOG_LINES=($GIT_LOG) 62 LF=$'\n' 63 64 # Write the Commit Message to a file, "First Commit\nAll Commits" 65 echo "${GIT_LOG_LINES[3]:4}$LF$LF$GIT_LOG$LF" > $COMMIT_MESSAGE 66 echo Synced from $GITHUB_URL >> $COMMIT_MESSAGE 67 68 cat $COMMIT_MESSAGE 54 69 fi 55 70 … … 58 73 59 74 # Update the latest sync rev 60 svn propset github:lastSync $LATEST_GIT_REV $WORKING_DIR75 svn propset -q github:lastSync $LATEST_GIT_REV $WORKING_DIR 61 76 62 77 # Copy Github over SVN 78 # Process any Assets first (This is effectively this entire file boiled down to a few lines) 79 if [ -d $WORKING_DIR/_temp-github/assets/ ]; then 80 cd $ASSETS_WORKING_DIR 81 svn co --non-interactive --force -q $ASSETS_SVN_URL $ASSETS_WORKING_DIR 82 rm -rf $ASSETS_WORKING_DIR/* 83 mv -f $WORKING_DIR/_temp-github/assets/* $ASSETS_WORKING_DIR/ 84 rmdir $WORKING_DIR/_temp-github/assets 85 svn st $ASSETS_WORKING_DIR | grep ^? | awk '{print $2}' | xargs -I % svn add --force % 86 svn st $ASSETS_WORKING_DIR | grep ^! | awk '{print $2}' | xargs -I % svn rm --force % 87 cd $WORKING_DIR 88 fi 89 90 # Next copy the rest of the plugin files 63 91 mv -f $WORKING_DIR/_temp-github/* $WORKING_DIR/ 64 92 rm -rf $WORKING_DIR/_temp-github 65 93 66 # Do the version number bump with $date (0.1-2015 -01-25)94 # Do the version number bump with $date (0.1-20150125) 67 95 # Will error if no .php files exist 68 96 MAIN_PLUGIN_FILE=$(grep 'Plugin Name:' $WORKING_DIR/*.php -l | head -n1) … … 73 101 74 102 # Add/Delete the world 75 svn st | grep ^? | awk '{print $2}' | xargs -I % svn add --force %76 svn st | grep ^! | awk '{print $2}' | xargs -I % svn rm --force %103 svn st $WORKING_DIR | grep ^? | awk '{print $2}' | xargs -I % svn add --force % 104 svn st $WORKING_DIR | grep ^! | awk '{print $2}' | xargs -I % svn rm --force % 77 105 78 106 # Check it in! 107 # Asset commit will only go through if there's new assets, trunk commit will always happen (at a minimum to bump lastSync) 108 svn ci --non-interactive $ASSETS_WORKING_DIR -F $COMMIT_MESSAGE --username $PHP_SVN_USER --password $PHP_SVN_PASSWORD 79 109 svn ci --non-interactive $WORKINGDIR -F $COMMIT_MESSAGE --username $PHP_SVN_USER --password $PHP_SVN_PASSWORD 80 110
Note: See TracChangeset
for help on using the changeset viewer.