Skip to content

Commit

Permalink
Plugin Directory: Allow the plugin management user commits to be impo…
Browse files Browse the repository at this point in the history
…rted into the Plugin Directory.

This allows for automated commits from the plugin directory to be processed as normal, while still skipping over irrelevant items.

See #343.
See #7783.


git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14253 74240141-8908-4e6f-9713-ba540dce6ec7
  • Loading branch information
dd32 committed Dec 10, 2024
1 parent 46bd88f commit fdc0837
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public function approved_create_svn_repo( $post, $plugin_author = null ) {
$dir,
'http://plugins.svn.wordpress.org/' . $post->post_name,
sprintf(
// WARNING: When changing this, please update the regex in SVN_Watcher::get_plugin_changes_between().
'Adding %1$s by %2$s.',
html_entity_decode( $post->post_title ),
$plugin_author->user_login
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public function watch() {
* @return array A list of plugin changes to process.
*/
protected function get_plugin_changes_between( $rev, $head_rev = 'HEAD' ) {

$logs = SVN::log( self::SVN_URL, array( $rev, $head_rev ) );
if ( $logs['errors'] ) {
if ( wp_cache_get( 'get_plugin_changes_between_failed', 'svn-watch' ) ) {
Expand Down Expand Up @@ -94,9 +93,27 @@ protected function get_plugin_changes_between( $rev, $head_rev = 'HEAD' ) {
$plugins = array();

foreach ( $logs['log'] as $log ) {
// Discard automated changes, these should not trigger plugin imports
if ( defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) && PLUGIN_SVN_MANAGEMENT_USER == $log['author'] ) {
continue;
// Discard some commits from the plugin management user.
if (
defined( 'PLUGIN_SVN_MANAGEMENT_USER' ) &&
PLUGIN_SVN_MANAGEMENT_USER == $log['author']
) {
/*
* If the commit matches the "new repo created" message, we'll skip it.
*
* See Status_Transitions::approved_create_svn_repo()
*/
if ( preg_match( '/^Adding (.+) by (.+)\.$/i', $log['msg'] ) ) {
continue;
}

/*
* If the commit includes an "Author:" byline, we'll use that as the actual author.
* This can be used for automated commits that are made on behalf of a user.
*/
if ( preg_match( '/^Author: (.+)\.$/im', $log['msg'], $matches ) ) {
$log['author'] = $matches[1];
}
}

$plugin_slug = explode( '/', $log['paths'][0] )[1];
Expand Down

0 comments on commit fdc0837

Please sign in to comment.