Making WordPress.org


Ignore:
Timestamp:
04/27/2016 06:01:49 PM (9 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/admin/class-status-transitions.php

    r2996 r3026  
    8383
    8484        // Create SVN repo.
    85         $svn_dirs = array(
    86             "{$post->post_name}/",
    87             "{$post->post_name}/trunk",
    88             "{$post->post_name}/branches",
    89             "{$post->post_name}/tags",
    90             "{$post->post_name}/assets",
    91         );
    92         SVN::mkdir( $svn_dirs, array(
    93             'message' => sprintf( 'Adding %1$s by %2$s.', $post->post_title, $plugin_author->user_login ),
     85        $dir = Filesystem::temp_directory( $post->post_name );
     86        $dir = Filesystem::unzip( get_attached_file( $attachment->ID ), $dir );
     87        foreach ( array( 'assets', 'branches', 'tags', 'trunk' ) as $folder ) {
     88            mkdir( "$dir/$folder", 0777 );
     89        }
     90
     91        $plugin_root = $this->get_plugin_root( $dir );
     92        // If there is no plugin file we have nothing to commit. Bail.
     93        if ( empty( $plugin_root ) ) {
     94            return;
     95        }
     96        rename( $plugin_root, "$dir/trunk" );
     97
     98        SVN::import( $dir, 'http://plugins.svn.wordpress.org/' . $post->post_name, array(
     99            'm'        => sprintf( 'Adding %1$s by %2$s.', $post->post_title, $plugin_author->user_login ),
     100            'username' => AUTOMATTIC_SVN_TRACKER__SVN_USER,
     101            'password' => AUTOMATTIC_SVN_TRACKER__SVN_PASSWORD,
    94102        ) );
    95 
    96         // Read zip and add/commit files to svn.
    97         SVN::add( Filesystem::unzip( get_attached_file( $attachment->ID ) ) );
    98103
    99104        // Delete zip.
     
    148153        wp_mail( $email, $subject, $content, 'From: plugins@wordpress.org' );
    149154    }
     155
     156    /**
     157     * Returns the path to a plugins root directory.
     158     *
     159     * @param string $dir Directory to search in.
     160     * @return string
     161     */
     162    private function get_plugin_root( $dir ) {
     163        $plugin_root  = '';
     164        $plugin_files = Filesystem::list_files( $dir, true /* Recursive */, '!\.php$!i' );
     165
     166        foreach ( $plugin_files as $plugin_file ) {
     167
     168            // No markup/translation needed.
     169            $plugin_data = get_plugin_data( $plugin_file, false, false );
     170
     171            if ( ! empty( $plugin_data['Name'] ) ) {
     172                $plugin_root = dirname( $plugin_file );
     173                break;
     174            }
     175        }
     176
     177        return $plugin_root;
     178    }
    150179}
Note: See TracChangeset for help on using the changeset viewer.