Making WordPress.org


Ignore:
Timestamp:
04/27/2016 06:01:49 PM (10 years ago)
Author:
obenland
Message:

Plugin Directory: Import plugin files to SVN upon approval.

We need to create an SVN repo anyway, adding the approved files also gives us
a nice baseline to compare commits to. And it saves plugin authors one more
step in the process of initially publishing the plugin.

See #1570.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/tools/class-svn.php

    r2999 r3026  
    99class SVN {
    1010
    11         public static function add( $dirs, $args = array() ) {
    12                 return true;
     11        /**
     12         * Create an SVN Export of a local directory to a URL.
     13         *
     14         * Note: An exception will be thrown upon SVN error.
     15         *
     16         * @param string $path    The local folder to import into SVN.
     17         * @param string $url     The URL to import to.
     18         * @param array  $options A list of options to pass to SVN. Optional.
     19         *
     20         * @return array {
     21         *   @type bool $result   The result of the operation.
     22         *   @type int  $revision The revision imported.
     23         * }
     24         */
     25        public static function import( $path, $url, $options = array() ) {
     26                $esc_options = self::parse_esc_parameters( $options );
     27
     28                $esc_path = escapeshellarg( $path );
     29                $esc_url  = escapeshellarg( $url );
     30
     31                $output = shell_exec( "svn import $esc_options $esc_path $esc_url 2>&1" );
     32                if ( preg_match( '/Committed revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
     33                        $revision = (int) $m['revision'];
     34                        $result   = true;
     35                } else {
     36                        $result = false;
     37                        $errors = self::parse_svn_errors( $output );
     38                }
     39
     40                return compact( 'result', 'revision', 'errors' );
    1341        }
    1442
     
    4068                        $result = false;
    4169                        $errors = self::parse_svn_errors( $output );
    42                        
    4370                }
    4471
     
    84111        }
    85112
    86         public static function mkdir( $dirs, $args = array() ) {
    87                 return true;
    88         }
    89 
    90113        /**
    91114         * Parse and escape the provided SVN arguements for usage on the CLI.
     
    109132                                $key = '-' . ( strlen( $key ) > 2 ? '-' : '' ) . $key;
    110133                        }
    111                        
     134
    112135                        $result[] = escapeshellarg( $key ) . ( $no_parameters ? '' : '=' . escapeshellarg( $value ) );
    113136                }
Note: See TracChangeset for help on using the changeset viewer.