Making WordPress.org

Changeset 12588


Ignore:
Timestamp:
05/16/2023 06:18:39 AM (13 months ago)
Author:
dd32
Message:

Plugin Directory: Release Confirmation: Allow building a older branch release without confirming the next-stable release.

See #5901.

File:
1 edited

Legend:

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

    r12587 r12588  
    7373        $data = $this->export_and_parse_plugin( $plugin_slug );
    7474
    75         $readme          = $data['readme'];
    76         $assets          = $data['assets'];
    77         $headers         = $data['plugin_headers'];
    78         $stable_tag      = $data['stable_tag'];
    79         $last_committer  = $data['last_committer'];
    80         $last_revision   = $data['last_revision'];
    81         $tagged_versions = $data['tagged_versions'];
    82         $last_modified   = $data['last_modified'];
    83         $blocks          = $data['blocks'];
    84         $block_files     = $data['block_files'];
     75        $readme             = $data['readme'];
     76        $assets             = $data['assets'];
     77        $headers            = $data['plugin_headers'];
     78        $stable_tag         = $data['stable_tag'];
     79        $last_committer     = $data['last_committer'];
     80        $last_revision      = $data['last_revision'];
     81        $tagged_versions    = $data['tagged_versions'];
     82        $last_modified      = $data['last_modified'];
     83        $blocks             = $data['blocks'];
     84        $block_files        = $data['block_files'];
     85        $current_stable_tag = get_post_meta( $plugin->ID, 'stable_tag', true ) ?: 'trunk';
     86        $touches_stable_tag = (bool) array_intersect( [ $stable_tag, $current_stable_tag ], $svn_changed_tags );
    8587
    8688        // Release confirmation
     
    131133            if ( ! $release ) {
    132134                throw new Exception( "Plugin release {$stable_tag} not found." );
     135            }
     136
     137            /*
     138             * If the stable release isn't confirmed, the next section will abort processing,
     139             * but if this commit didn't touch a stable tag, but rather a confirmed release tag,
     140             * then we need to build a new zip for that tag.
     141             *
     142             * This is required as ZIP building occurs at the end of the import process, yet with
     143             * release confirmations the
     144             */
     145            if ( ! $release['confirmed'] && ! $touches_stable_tag ) {
     146                $zips_to_build = [];
     147                foreach ( $svn_changed_tags as $svn_changed_tag ) {
     148                    // We're not concerned with trunk or stable tags.
     149                    if ( 'trunk' === $svn_changed_tag || $svn_changed_tag === $stable_tag ) {
     150                        continue;
     151                    }
     152
     153                    $this_release = Plugin_Directory::get_release( $plugin, $svn_changed_tag );
     154                    if ( $this_release['confirmed'] && ! $this_release['zips_built'] ) {
     155                        $zips_to_build[] = $this_release['tag'];
     156                    }
     157                }
     158
     159                if ( $zips_to_build ) {
     160                    // NOTE: $stable_tag not passed, as it's not yet stable and won't be.
     161                    $this->rebuild_affected_zips( $plugin_slug, $current_stable_tag, $current_stable_tag, $zips_to_build, $svn_revision_triggered );
     162                }
    133163            }
    134164
     
    322352        }
    323353
    324         $current_stable_tag = get_post_meta( $plugin->ID, 'stable_tag', true ) ?: 'trunk';
    325 
    326354        $this->rebuild_affected_zips( $plugin_slug, $stable_tag, $current_stable_tag, $svn_changed_tags, $svn_revision_triggered );
    327355
     
    388416                $release = Plugin_Directory::get_release( $plugin, $tag );
    389417
    390                 if ( ! $release || ! $release['confirmed'] || $release['zips_built'] ) {
     418                if (
     419                    // If the release isn't known, skip.
     420                    ! $release ||
     421                    // If the release isn't confirmed AND confirmations were required, skip.
     422                    ( ! $release['confirmed'] && $release['confirmations_required'] ) ||
     423                    // If the release has had its ZIPs built, skip if it required confirmations.
     424                    ( $release['zips_built'] && $release['confirmations_required'] )
     425                ) {
    391426                    unset( $versions_to_build[ $i ] );
    392427                } else {
     
    394429                    Plugin_Directory::add_release( $plugin, $release );
    395430                }
    396 
     431            }
     432
     433            if ( $versions_to_build ) {
     434                echo "Building ZIPs for {$plugin_slug}: " . implode( ', ', $versions_to_build ) . "\n";
    397435            }
    398436        }
Note: See TracChangeset for help on using the changeset viewer.