Making WordPress.org

Changeset 1207


Ignore:
Timestamp:
01/30/2015 01:05:23 AM (9 years ago)
Author:
dd32
Message:

Feature plugin Github syncing: Add Press-This as a valid repo, updates to the script to handle the assets directory.

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  
    55
    66require dirname( dirname( __DIR__ ) ) . '/init.php';
    7 require WPORGPATH . '/.config/secrets.php';
    87
    98class GH2WORG {
     
    1211        // Github User/Repo => plugins.svn.wordpress.org/****/trunk/
    1312        'dd32/feature-plugin-testing' => 'test-plugin-3',
     13        'MichaelArestad/Press-This' => 'press-this',
    1414    );
    1515
     
    4848        list( $algo, $hash ) = explode( '=', $_SERVER['HTTP_X_HUB_SIGNATURE'], 2 );
    4949
    50         // Todo? Doesn't handle standard $_POST
     50        // Todo? Doesn't handle standard $_POST, only application/json
    5151        $hmac = hash_hmac( $algo, file_get_contents('php://input' ), FEATURE_PLUGIN_GH_SYNC_SECRET );
    5252
     
    6363        putenv( 'PHP_SVN_PASSWORD=' . FEATURE_PLUGIN_GH_SYNC_PASS );
    6464
    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" );
    6866
    6967        putenv( 'PHP_SVN_USER' );
  • sites/trunk/api.wordpress.org/public_html/dotorg/github-sync/feature-plugins.sh

    r1185 r1207  
    33GITHUB_URL=$1;
    44SVN_PLUGIN=$2;
     5
     6# Split by newlines only in bash arrays
     7IFS=$'\r\n'
    58
    69# ENV vars: $PHP_SVN_USER, $PHP_SVN_PASSWORD
     
    1114
    1215SVN_URL="https://plugins.svn.wordpress.org/$SVN_PLUGIN/trunk/"
     16ASSETS_SVN_URL="https://plugins.svn.wordpress.org/$SVN_PLUGIN/assets/"
    1317
    1418WORKING_DIR=$(mktemp -d /tmp/gh-plugin-sync-XXXXXXX)
     19ASSETS_WORKING_DIR=$(mktemp -d /tmp/gh-plugin-assets-XXXXXXX)
    1520COMMIT_MESSAGE=$(mktemp /tmp/gh-plugin-sync-commit-XXXXXX)
    1621function finish {
    1722    rm -rf "$WORKING_DIR"
    1823    rm -rf "$COMMIT_MESSAGE"
    19     echo Script Done.
     24    rm -rf "$ASSETS_WORKING_DIR"
     25    echo Sync Done.
    2026}
    2127trap finish EXIT
     
    2329cd $WORKING_DIR
    2430
    25 echo $(uname -n | sed 's/.wordpress.org$//') Merging from $GITHUB_URL to $SVN_URL
     31echo Merging from $GITHUB_URL to $SVN_URL
    2632
    2733# Checkout
    28 svn co --non-interactive --force $SVN_URL $WORKING_DIR 2>&1
     34svn co --non-interactive --force -q $SVN_URL $WORKING_DIR 2>&1
    2935
    3036# Get the last GIT Rev sync
     
    5056if [ $LAST_GIT_SYNC_REV ]; then
    5157    # 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
    5469fi
    5570
     
    5873
    5974# Update the latest sync rev
    60 svn propset github:lastSync $LATEST_GIT_REV $WORKING_DIR
     75svn propset -q github:lastSync $LATEST_GIT_REV $WORKING_DIR
    6176
    6277# Copy Github over SVN
     78# Process any Assets first (This is effectively this entire file boiled down to a few lines)
     79if [ -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
     88fi
     89
     90# Next copy the rest of the plugin files
    6391mv -f $WORKING_DIR/_temp-github/* $WORKING_DIR/
    6492rm -rf $WORKING_DIR/_temp-github
    6593
    66 # Do the version number bump with $date (0.1-2015-01-25)
     94# Do the version number bump with $date (0.1-20150125)
    6795# Will error if no .php files exist
    6896MAIN_PLUGIN_FILE=$(grep 'Plugin Name:' $WORKING_DIR/*.php -l | head -n1)
     
    73101
    74102# 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 %
     103svn st $WORKING_DIR | grep ^? | awk '{print $2}' | xargs -I % svn add --force %
     104svn st $WORKING_DIR | grep ^! | awk '{print $2}' | xargs -I % svn rm --force %
    77105
    78106# 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)
     108svn ci --non-interactive $ASSETS_WORKING_DIR -F $COMMIT_MESSAGE --username $PHP_SVN_USER --password $PHP_SVN_PASSWORD
    79109svn ci --non-interactive $WORKINGDIR -F $COMMIT_MESSAGE --username $PHP_SVN_USER --password $PHP_SVN_PASSWORD
    80110
Note: See TracChangeset for help on using the changeset viewer.