diff --git a/Source/Source.API.php b/Source/Source.API.php index e897ac7..2b29594 100644 --- a/Source/Source.API.php +++ b/Source/Source.API.php @@ -56,8 +56,8 @@ function Source_Parse_Buglinks( $p_string ) { $t_bugs = array(); - $t_regex1 = config_get( 'plugin_Source_buglink_regex_1' ); - $t_regex2 = config_get( 'plugin_Source_buglink_regex_2' ); + $t_regex1 = plugin_config_get( 'buglink_regex_1', null, 'Source' ); + $t_regex2 = plugin_config_get( 'buglink_regex_2', null, 'Source' ); preg_match_all( $t_regex1, $p_string, $t_matches_all ); @@ -74,6 +74,27 @@ } /** + * Given a set of changeset objects, parse the bug links + * and save the changes. + * @param array Changeset objects + */ +function Source_Process_Buglinks( $p_changesets ) { + if ( !is_array( $p_changesets ) ) { + return; + } + + # Parse normal bug links + foreach( $p_changesets as $t_changeset ) { + $t_changeset->bugs = Source_Parse_Buglinks( $t_changeset->message ); + } + + # Save changes + foreach( $p_changesets as $t_changeset ) { + $t_changeset->save(); + } +} + +/** * preg_replace_callback function for working with VCS links. */ function Source_Changeset_Link_Callback( $p_matches ) { diff --git a/Source/pages/checkin.php b/Source/pages/checkin.php index db8ab2f..d9d98b4 100644 --- a/Source/pages/checkin.php +++ b/Source/pages/checkin.php @@ -89,6 +89,8 @@ die( plugin_lang_get( 'invalid_changeset' ) ); } +Source_Process_Buglinks( $t_changesets ); + # Allow plugins to handle commits afterwards event_signal( 'EVENT_SOURCE_POSTCOMMIT', array( $t_repo, $t_changesets ) ); diff --git a/Source/pages/repo_import_full.php b/Source/pages/repo_import_full.php index 722c393..9f6b35c 100644 --- a/Source/pages/repo_import_full.php +++ b/Source/pages/repo_import_full.php @@ -29,9 +29,11 @@ $t_new_repo->name = 'Import ' . date( 'Y-m-d H:i:s' ); $t_new_repo->save(); -$t_status = event_signal( 'EVENT_SOURCE_IMPORT_FULL', array( $t_new_repo ) ); +$t_changesets = event_signal( 'EVENT_SOURCE_IMPORT_FULL', array( $t_new_repo ) ); -if ( $t_status ) { +if ( is_array( $t_changesets ) ) { + Source_Process_Buglinks( $t_changesets ); + $t_new_repo->name = $t_repo->name; $t_new_repo->save(); diff --git a/Source/pages/repo_import_latest.php b/Source/pages/repo_import_latest.php index b30041b..8243045 100644 --- a/Source/pages/repo_import_latest.php +++ b/Source/pages/repo_import_latest.php @@ -90,6 +90,8 @@ if ( !is_array( $t_changesets ) ) { echo plugin_lang_get( 'import_latest_failed' ), '
'; } else { + Source_Process_Buglinks( $t_changesets ); + event_signal( 'EVENT_SOURCE_POSTIMPORT', array( $t_repo, $t_changesets ) ); }