Commit 111be47a authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4474 (Improve push_bugfix addon detection)

parent c251d0db
Loading
Loading
Loading
Loading
+46 −14
Original line number Diff line number Diff line
@@ -358,24 +358,56 @@ END;
        function update_automatic_category()
        {
            // See if we can match all the selected files to a particular category
            var fixed_files = [];
            var fixed_files_e = document.getElementById('fixed_files');
            var file_addons = {$_git_found};
            var category_title = 'core';
            var category_title = null;
            for (var i = 0; i < fixed_files_e.options.length; i++) {
                if (fixed_files_e.options[i].selected) {
                    var filename = fixed_files_e.options[i].value;
                    fixed_files.push(fixed_files_e.options[i].value);
                }
            }
            for (var i = 0; i < fixed_files.length; i++) {
                var filename = fixed_files[i];
                if ((typeof file_addons[filename] != 'undefined') && (file_addons[filename] !== null)) {
                        if (category_title.match(/^core(_.*)?$/)) {
                            category_title = file_addons[filename];
                    if (category_title === null) {
                        category_title = file_addons[filename]; // Nice match to a bundled addon
                    } else if ((file_addons[filename] != category_title) && (!file_addons[filename].match(/^core(_.*)?$/))) {
                            category_title = 'core'; // Conflict, so bump it back to core
                        category_title = 'core'; // Conflict with something other than core, so bump it back to core as a generalisation
                        break; // ... and stop trying
                    }
                    } else {
                }
            }
            if (category_title === null) {
                category_title = 'General'; // Must be from non-bundled addon
                        break; // ... and stop trying
            }

            // Find some special general matches
            var is_all_tests = true;
            var is_all_documentation = true;
            var is_all_build_tools = true;
            for (var i = 0; i < fixed_files.length; i++) {
                var filename = fixed_files[i];
                if (!filename.match(/^_tests\//)) {
                    is_all_tests = false;
                }
                if (!filename.match(/^docs\//)) {
                    is_all_documentation = false;
                }
                if (!['sources_custom/make_release.php', 'adminzone/pages/minimodules_custom/make_release.php', 'adminzone/pages/minimodules_custom/push_bugfix.php'].includes(filename)) {
                    is_all_build_tools = false;
                }

            }
            var correct_general_project = '4';
            if (is_all_tests) {
                correct_general_project = '9';
            }
            if (is_all_documentation) {
                correct_general_project = '7';
            }
            if (is_all_build_tools) {
                correct_general_project = '8';
            }

            // Now select that category
@@ -390,7 +422,7 @@ END;
            // Now select the corresponding project
            var project_e = document.getElementById('project');
            for (var i = 0; i < project_e.options.length; i++) {
                if (((project_e.options[i].value == '{$default_project_id}') && (category_title != 'General')) || ((project_e.options[i].value == '4') && (category_title == 'General'))) {
                if (((project_e.options[i].value == '{$default_project_id}') && (category_title != 'General')) || ((project_e.options[i].value == correct_general_project) && (category_title == 'General'))) {
                    project_e.selectedIndex = i;
                    break;
                }