Making WordPress.org

Changeset 5207


Ignore:
Timestamp:
03/30/2017 08:01:03 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: Tools: Add a SVN::mkdir() method.

File:
1 edited

Legend:

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

    r5147 r5207  
    194194
    195195        $output = self::shell_exec( "svn commit $esc_options $esc_checkout 2>&1" );
     196        if ( preg_match( '/Committed revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
     197            $revision = (int) $m['revision'];
     198            $result   = true;
     199        } else {
     200            $result = false;
     201            $errors = self::parse_svn_errors( $output );
     202        }
     203
     204        return compact( 'result', 'revision', 'errors' );
     205    }
     206
     207    /**
     208     * Create a folder at a specified SVN location.
     209     *
     210     * @static
     211     *
     212     * @param string $url      The remote URL to create.
     213     * @param string $message  The commit message.
     214     * @param array  $options  Any specific options to pass to SVN.
     215     * @return array {
     216     *     @type bool $result   The result of the operation.
     217     *     @type int  $revision The revision imported.
     218     * }
     219     */
     220    public static function mkdir( $url, $message, $options = array() ) {
     221        $options[] = 'non-interactive';
     222        $options['m'] = $message;
     223        if ( empty( $options['username'] ) ) {
     224            $options['username'] = PLUGIN_SVN_MANAGEMENT_USER;
     225            $options['password'] = PLUGIN_SVN_MANAGEMENT_PASS;
     226        }
     227
     228        $esc_options = self::parse_esc_parameters( $options );
     229
     230        $esc_checkout = escapeshellarg( $url );
     231
     232        $output = self::shell_exec( "svn mkdir $esc_options $esc_checkout 2>&1" );
    196233        if ( preg_match( '/Committed revision (?P<revision>\d+)[.]/i', $output, $m ) ) {
    197234            $revision = (int) $m['revision'];
Note: See TracChangeset for help on using the changeset viewer.