diff --git a/Source/Source.API.php b/Source/Source.API.php index 7427f0f..587d10c 100644 --- a/Source/Source.API.php +++ b/Source/Source.API.php @@ -284,6 +284,7 @@ $t_enable_mapping = config_get( 'plugin_Source_enable_mapping' ); $t_bugfix_status = config_get( 'plugin_Source_bugfix_status' ); + $t_bugfix_status_pvm = config_get( 'plugin_Source_bugfix_status_pvm' ); $t_resolution = config_get( 'plugin_Source_bugfix_resolution' ); $t_handler = config_get( 'plugin_Source_bugfix_handler' ); $t_message_template = str_replace( @@ -317,8 +318,9 @@ $g_cache_current_user_id = 0; } - # generate the branch mapping + # generate the branch mappings $t_version = ''; + $t_pvm_version_id = 0; if ( $t_enable_mapping ) { $t_repo_id = $t_changeset->repo_id; @@ -328,7 +330,11 @@ if ( isset( $t_mappings[ $t_repo_id ][ $t_changeset->branch ] ) ) { $t_mapping = $t_mappings[ $t_repo_id ][ $t_changeset->branch ]; - $t_version = $t_mapping->apply( $t_bug_id ); + if ( Source_PVM() ) { + $t_pvm_version_id = $t_mapping->apply_pvm( $t_bug_id ); + } else { + $t_version = $t_mapping->apply( $t_bug_id ); + } } } @@ -341,39 +347,49 @@ $t_bug = bug_get( $t_bug_id ); - # Resolve any fixed bugs that are not already marked as resolved - if ( $t_enable_resolving && $t_bugfix_status == -1 && $t_bug->status < $t_resolved_threshold ) { - bug_resolve( $t_bug_id, $t_resolution, $t_version, $t_message, null, $t_handler == ON ? $t_user_id : null ); + # Update the resoltion, fixed-in version, or add a bugnote + $t_update = false; - # Optionally update the resoltion, fixed-in version, or add a bugnote + if ( Source_PVM() ) { + if ( $t_bugfix_status_pvm > 0 && $t_pvm_version_id > 0 ) { + $t_matrix = new ProductMatrix( $t_bug_id ); + if ( isset( $t_matrix->status[ $t_pvm_version_id ] ) ) { + $t_matrix->status[ $t_pvm_version_id ] = $t_bugfix_status_pvm; + $t_matrix->save(); + } + } + } else { - $t_update = false; - if ( $t_bugfix_status > 0 && $t_bug->status != $t_bugfix_status ) { $t_bug->status = $t_bugfix_status; $t_update = true; + } else if ( $t_bugfix_status == -1 && $t_bug->status < $t_resolved_threshold ) { + $t_bug->status = $t_resolved_threshold; + $t_update = true; } + if ( $t_bug->resolution < $t_fixed_threshold || $t_bug->resolution >= $t_notfixed_threshold ) { $t_bug->resolution = $t_resolution; $t_update = true; } - if ( $t_handler && !is_null( $t_user_id ) ) { - $t_bug->handler_id = $t_user_id; - } if ( is_blank( $t_bug->fixed_in_version ) ) { $t_bug->fixed_in_version = $t_version; $t_update = true; } + } - if ( $t_update ) { - if ( $t_message ) { - bugnote_add( $t_bug_id, $t_message, '0:00', false, 0, '', null, false ); - } - $t_bug->update(); + if ( $t_handler && !is_null( $t_user_id ) ) { + $t_bug->handler_id = $t_user_id; + } - } else if ( $t_message ) { - bugnote_add( $t_bug_id, $t_message ); + if ( $t_update ) { + if ( $t_message ) { + bugnote_add( $t_bug_id, $t_message, '0:00', false, 0, '', null, false ); } + $t_bug->update(); + + } else if ( $t_message ) { + bugnote_add( $t_bug_id, $t_message ); } } @@ -1420,6 +1436,22 @@ return ''; } + /** + * Given a bug ID, apply the appropriate branch mapping algorithm + * to find and return the appropriate product matrix version ID. + * @param int Bug ID + * @return int Product version ID + */ + function apply_pvm( $p_bug_id ) { + # if it's explicit, return the version_id before doing anything else + if ( $this->type == SOURCE_EXPLICIT ) { + return $this->pvm_version_id; + } + + # no version matches the regex + return 0; + } + function cmp_near( $a, $b ) { return strcmp( $a['date_order'], $b['date_order'] ); } diff --git a/Source/Source.php b/Source/Source.php index f4ea725..5239fd4 100644 --- a/Source/Source.php +++ b/Source/Source.php @@ -57,6 +57,7 @@ 'bugfix_regex_2' => '/#?(\d+)/', 'bugfix_status' => -1, 'bugfix_resolution' => FIXED, + 'bugfix_status_pvm' => 0, 'bugfix_handler' => ON, 'bugfix_message' => 'Fix committed to $1 branch.', diff --git a/Source/lang/strings_english.txt b/Source/lang/strings_english.txt index b4959be..cbe3ea2 100644 --- a/Source/lang/strings_english.txt +++ b/Source/lang/strings_english.txt @@ -87,6 +87,7 @@ $s_plugin_Source_bugfix_regex_1 = 'Bug Fixed Regex Pass 1'; $s_plugin_Source_bugfix_regex_2 = 'Bug Fixed Regex Pass 2'; $s_plugin_Source_bugfix_status = 'Bug Fixed Status'; +$s_plugin_Source_bugfix_status_pvm = 'Bug Fixed Product Status'; $s_plugin_Source_bugfix_status_off = '[Disabled]'; $s_plugin_Source_bugfix_status_default = '[Resolved Status]'; $s_plugin_Source_bugfix_resolution = 'Bug Fixed Resolution'; diff --git a/Source/pages/manage_config.php b/Source/pages/manage_config.php index 563b93d..587e862 100644 --- a/Source/pages/manage_config.php +++ b/Source/pages/manage_config.php @@ -34,6 +34,7 @@ $f_bugfix_reset_2 = gpc_get_string( 'bugfix_reset_2', OFF ); $f_bugfix_status = gpc_get_int( 'bugfix_status' ); $f_bugfix_resolution = gpc_get_int( 'bugfix_resolution' ); +$f_bugfix_status_pvm = gpc_get_int( 'bugfix_status_pvm' ); $f_bugfix_handler = gpc_get_bool( 'bugfix_handler' ); $f_bugfix_message = gpc_get_string( 'bugfix_message' ); @@ -110,6 +111,7 @@ maybe_set_option( 'bugfix_status', $f_bugfix_status ); maybe_set_option( 'bugfix_resolution', $f_bugfix_resolution ); +maybe_set_option( 'bugfix_status_pvm', $f_bugfix_status_pvm ); maybe_set_option( 'bugfix_handler', $f_bugfix_handler ); maybe_set_option( 'bugfix_message', $f_bugfix_message ); diff --git a/Source/pages/manage_config_page.php b/Source/pages/manage_config_page.php index 3b36623..341e641 100644 --- a/Source/pages/manage_config_page.php +++ b/Source/pages/manage_config_page.php @@ -130,6 +130,18 @@ + +> + + + + + >
diff --git a/Source/pages/repo_manage_page.php b/Source/pages/repo_manage_page.php index 9d9afc6..baebf2e 100644 --- a/Source/pages/repo_manage_page.php +++ b/Source/pages/repo_manage_page.php @@ -24,11 +24,11 @@ '>', plugin_lang_get( 'mapping_near' ), '', ''; - } echo '', ''; + } } function display_pvm_versions($t_version_id=null) {