| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | if ( 'cli' != php_sapi_name() || $argc < 3 )
|
|---|
| 4 | exit;
|
|---|
| 5 |
|
|---|
| 6 | $user = $argv[1];
|
|---|
| 7 | $password = $argv[2];
|
|---|
| 8 |
|
|---|
| 9 | $bin = dirname( __FILE__ );
|
|---|
| 10 | $repo = 'https://core.svn.wordpress.org';
|
|---|
| 11 | $yui = $bin . '/yuicompressor-2.4.2.jar';
|
|---|
| 12 | if ( ! file_exists( $yui ) )
|
|---|
| 13 | exit;
|
|---|
| 14 |
|
|---|
| 15 | $yui = "java -jar $yui -v";
|
|---|
| 16 |
|
|---|
| 17 | $start = microtime( true );
|
|---|
| 18 |
|
|---|
| 19 | if ( ! is_dir( "$bin/trunk" ) )
|
|---|
| 20 | echo `svn checkout --ignore-externals $repo/trunk $bin/trunk`;
|
|---|
| 21 |
|
|---|
| 22 | chdir( "$bin/trunk" );
|
|---|
| 23 |
|
|---|
| 24 | // Just in case.
|
|---|
| 25 | echo `svn cleanup; svn revert -R *`;
|
|---|
| 26 |
|
|---|
| 27 | $find_rev = `svn up --ignore-externals`;
|
|---|
| 28 |
|
|---|
| 29 | if ( ! preg_match( '/^At revision (\d+)\.$/', $find_rev, $rev ) )
|
|---|
| 30 | exit( 'svn up failed.' . "\n" );
|
|---|
| 31 | $rev = $rev[1];
|
|---|
| 32 |
|
|---|
| 33 | // We can use this in the future. The bot can post warnings to Trac, for example.
|
|---|
| 34 | $output = array();
|
|---|
| 35 |
|
|---|
| 36 | foreach ( array( 'css', 'js' ) as $type ) {
|
|---|
| 37 | $files = explode( "\n", trim( `find . -name "*.dev.$type"` ) );
|
|---|
| 38 | foreach ( $files as $file ) {
|
|---|
| 39 | $file = substr( $file, 0, -strlen( ".dev.$type" ) );
|
|---|
| 40 | $result = trim( `$yui --type $type -o $file.$type $file.dev.$type 2>&1` );
|
|---|
| 41 | if ( false === strpos( $result, '[WARNING]' ) )
|
|---|
| 42 | $result = true;
|
|---|
| 43 | else
|
|---|
| 44 | $result = strstr( $result, '[WARNING]' );
|
|---|
| 45 | $output[ "$file.dev.$type" ] = $result;
|
|---|
| 46 | }
|
|---|
| 47 | }
|
|---|
| 48 |
|
|---|
| 49 | $diff = `svn stat --ignore-externals | grep ^M`;
|
|---|
| 50 | $diff = explode( "\n", $diff );
|
|---|
| 51 | foreach ( $diff as &$d )
|
|---|
| 52 | $d = trim( ltrim( $d, 'M' ) );
|
|---|
| 53 | $diff = array_filter( $diff );
|
|---|
| 54 |
|
|---|
| 55 | $stop = microtime(true) - $start;
|
|---|
| 56 |
|
|---|
| 57 | if ( empty( $diff ) )
|
|---|
| 58 | exit( 'Nothing to commit.' . "\n" );
|
|---|
| 59 |
|
|---|
| 60 | $version_php = file_get_contents( './wp-includes/version.php' );
|
|---|
| 61 |
|
|---|
| 62 | // 3.4-alpha-12345 to 3.4-alpha-12346
|
|---|
| 63 | if ( preg_match( "/wp_version = '(.*?)-(.*?)-(\d+)'/", $version_php, $matches ) )
|
|---|
| 64 | $version_php = preg_replace( "/wp_version = '(.*?)-(.*?)-(\d+)'/",
|
|---|
| 65 | 'wp_version = \'$1-$2-' . ( $rev + 1 ) . "'", $version_php );
|
|---|
| 66 | // 3.4-alpha to 3.4-alpha-12346
|
|---|
| 67 | elseif ( preg_match( "/wp_version = '(.*?)-(.*?)'/", $version_php, $matches ) )
|
|---|
| 68 | $version_php = preg_replace( "/wp_version = '(.*?)-(.*?)'/",
|
|---|
| 69 | 'wp_version = \'$1-$2-' . ( $rev + 1 ) . "'", $version_php );
|
|---|
| 70 | // 3.4
|
|---|
| 71 | else
|
|---|
| 72 | exit( "Stable release. Don't touch!" . "\n" );
|
|---|
| 73 |
|
|---|
| 74 | file_put_contents( './wp-includes/version.php', $version_php );
|
|---|
| 75 |
|
|---|
| 76 | $user = escapeshellarg( $user );
|
|---|
| 77 | $password = escapeshellarg( $password );
|
|---|
| 78 | $msg = escapeshellarg( 'Compress scripts/styles: ' . $matches[1] . '-' . $matches[2] . '-' . ( $rev + 1 ) . '.' );
|
|---|
| 79 |
|
|---|
| 80 | #echo `svn diff`;
|
|---|
| 81 | echo `svn commit -m --no-auth-cache --non-interactive --username $user --password $password $msg`;
|
|---|
| 82 |
|
|---|
| 83 | exit( $msg . "\n" );
|
|---|