Changeset 4564
- Timestamp:
- 12/21/2016 07:40:41 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/class-import.php
r4520 r4564 283 283 $tmp_dir = Filesystem::temp_directory( "process-{$plugin_slug}" ); 284 284 285 // We assume the stable tag is trunk to start with. 286 $stable_tag = 'trunk'; 287 285 288 // Find the trunk readme file, list remotely to avoid checking out the entire directory. 286 $trunk_files = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/trunk" ); 289 $trunk_files = SVN::ls( self::PLUGIN_SVN_BASE . "/{$plugin_slug}/trunk" ) ?: array(); 290 291 // Find the list of tagged versions of the plugin. 292 $tagged_versions = SVN::ls( "https://plugins.svn.wordpress.org/{$plugin_slug}/tags/" ) ?: array(); 293 $tagged_versions = array_map( function( $item ) { 294 return rtrim( $item, '/' ); 295 }, $tagged_versions ); 296 297 // Not all plugins utilise `trunk`, some just tag versions. 287 298 if ( ! $trunk_files ) { 288 throw new Exception( 'Plugin has no files in trunk.' ); 299 if ( ! $tagged_versions ) { 300 throw new Exception( 'Plugin has no files in trunk, nor tags.' ); 301 } 302 303 $stable_tag = array_reduce( $tagged_versions, function( $a, $b ) { 304 return version_compare( $a, $b, '>' ) ? $a : $b; 305 } ); 289 306 } 290 307 … … 304 321 305 322 $stable_tag = $trunk_readme->stable_tag; 306 } else {307 $stable_tag = 'trunk';308 323 } 309 324 … … 338 353 } 339 354 if ( ! $exported ) { 355 // Catch the case where exporting a tag finds nothing, but there was nothing in trunk either. 356 if ( ! $trunk_files ) { 357 throw new Exception( 'Plugin has no files in trunk, nor tags.' ); 358 } 359 340 360 $stable_tag = 'trunk'; 341 361 // Either stable_tag = trunk, or the stable_tag tag didn't exist. … … 381 401 } 382 402 383 $tagged_versions = SVN::ls( "https://plugins.svn.wordpress.org/{$plugin_slug}/tags/" ) ?: array();384 $tagged_versions = array_map( function( $item ) {385 return rtrim( $item, '/' );386 }, $tagged_versions );387 388 403 // Find screenshots in the stable plugin folder (but don't overwrite /assets/) 389 404 foreach ( Filesystem::list_files( "$tmp_dir/export/", false /* non-recursive */, '!^screenshot-\d+\.(jpeg|jpg|png|gif)$!' ) as $plugin_screenshot ) {
Note: See TracChangeset
for help on using the changeset viewer.