diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-08 12:08:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-08 12:08:31 +0300 |
commit | 49a897eff9081b39665a4827b4f685e142569b99 (patch) | |
tree | 302e8c9fad985adb1302feda35cca079302cd542 | |
parent | a69bb17d1e46f2816c3406d24c4dcdcb6d479935 (diff) |
Add latest changes from gitlab-org/gitlab@master
79 files changed, 374 insertions, 261 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0c92efbcd8a..d26e433e923 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1132,13 +1132,7 @@ Rails/SaveBang: - 'spec/requests/api/issues/post_projects_issues_spec.rb' - 'spec/requests/api/jobs_spec.rb' - 'spec/requests/api/labels_spec.rb' - - 'spec/requests/api/merge_requests_spec.rb' - - 'spec/requests/api/notes_spec.rb' - - 'spec/requests/api/pipeline_schedules_spec.rb' - 'spec/requests/api/project_import_spec.rb' - - 'spec/requests/git_http_spec.rb' - - 'spec/requests/lfs_http_spec.rb' - - 'spec/requests/profiles/notifications_controller_spec.rb' - 'spec/requests/projects/cycle_analytics_events_spec.rb' - 'spec/services/auth/container_registry_authentication_service_spec.rb' - 'spec/services/auto_merge/base_service_spec.rb' diff --git a/app/assets/javascripts/alert_handler.js b/app/assets/javascripts/alert_handler.js new file mode 100644 index 00000000000..8fffb61d1dd --- /dev/null +++ b/app/assets/javascripts/alert_handler.js @@ -0,0 +1,13 @@ +// This allows us to dismiss alerts that we've migrated from bootstrap +// Note: This ONLY works on alerts that are created on page load +// You can follow this effort in the following epic +// https://gitlab.com/groups/gitlab-org/-/epics/4070 + +export default function initAlertHandler() { + const ALERT_SELECTOR = '.gl-alert'; + const CLOSE_SELECTOR = '.gl-alert-dismiss'; + + const dismissAlert = ({ target }) => target.closest(ALERT_SELECTOR).remove(); + const closeButtons = document.querySelectorAll(`${ALERT_SELECTOR} ${CLOSE_SELECTOR}`); + closeButtons.forEach(alert => alert.addEventListener('click', dismissAlert)); +} diff --git a/app/assets/javascripts/boards/components/board_list_header.vue b/app/assets/javascripts/boards/components/board_list_header.vue index 4eca6ed9fcc..c6c996a0074 100644 --- a/app/assets/javascripts/boards/components/board_list_header.vue +++ b/app/assets/javascripts/boards/components/board_list_header.vue @@ -96,10 +96,11 @@ export default { showAssigneeListDetails() { return this.list.type === 'assignee' && (this.list.isExpanded || !this.isSwimlanesHeader); }, + issuesCount() { + return this.list.issuesSize; + }, issuesTooltipLabel() { - const { issuesSize } = this.list; - - return n__(`%d issue`, `%d issues`, issuesSize); + return n__(`%d issue`, `%d issues`, this.issuesCount); }, chevronTooltip() { return this.list.isExpanded ? s__('Boards|Collapse') : s__('Boards|Expand'); @@ -299,7 +300,7 @@ export default { <gl-tooltip :target="() => $refs.issueCount" :title="issuesTooltipLabel" /> <span ref="issueCount" class="issue-count-badge-count"> <gl-icon class="gl-mr-2" name="issues" /> - <issue-count :issues-size="list.issuesSize" :max-issue-count="list.maxIssueCount" /> + <issue-count :issues-size="issuesCount" :max-issue-count="list.maxIssueCount" /> </span> <!-- The following is only true in EE. --> <template v-if="weightFeatureAvailable"> diff --git a/app/assets/javascripts/boards/index.js b/app/assets/javascripts/boards/index.js index 38211971589..c5dd1e0c459 100644 --- a/app/assets/javascripts/boards/index.js +++ b/app/assets/javascripts/boards/index.js @@ -161,7 +161,12 @@ export default () => { } }, methods: { - ...mapActions(['setInitialBoardData', 'setFilters', 'fetchEpicsSwimlanes']), + ...mapActions([ + 'setInitialBoardData', + 'setFilters', + 'fetchEpicsSwimlanes', + 'fetchIssuesForAllLists', + ]), updateTokens() { this.filterManager.updateTokens(); }, @@ -169,6 +174,7 @@ export default () => { this.setFilters(convertObjectPropsToCamelCase(urlParamsToObject(window.location.search))); if (gon.features.boardsWithSwimlanes && this.isShowingEpicsSwimlanes) { this.fetchEpicsSwimlanes(false); + this.fetchIssuesForAllLists(); } }, updateDetailIssue(newIssue, multiSelect = false) { diff --git a/app/assets/javascripts/boards/queries/group_lists_issues.query.graphql b/app/assets/javascripts/boards/queries/group_lists_issues.query.graphql deleted file mode 100644 index 724c7884c58..00000000000 --- a/app/assets/javascripts/boards/queries/group_lists_issues.query.graphql +++ /dev/null @@ -1,18 +0,0 @@ -#import "./issue.fragment.graphql" - -query GroupListIssues($fullPath: ID!, $boardId: ID!) { - group(fullPath: $fullPath) { - board(id: $boardId) { - lists { - nodes { - id - issues { - nodes { - ...IssueNode - } - } - } - } - } - } -} diff --git a/app/assets/javascripts/boards/queries/lists_issues.query.graphql b/app/assets/javascripts/boards/queries/lists_issues.query.graphql new file mode 100644 index 00000000000..a9fc99fd916 --- /dev/null +++ b/app/assets/javascripts/boards/queries/lists_issues.query.graphql @@ -0,0 +1,38 @@ +#import "./issue.fragment.graphql" + +query ListIssues( + $fullPath: ID! + $boardId: ID! + $filters: BoardIssueInput + $isGroup: Boolean = false + $isProject: Boolean = false +) { + group(fullPath: $fullPath) @include(if: $isGroup) { + board(id: $boardId) { + lists { + nodes { + id + issues(filters: $filters) { + nodes { + ...IssueNode + } + } + } + } + } + } + project(fullPath: $fullPath) @include(if: $isProject) { + board(id: $boardId) { + lists { + nodes { + id + issues(filters: $filters) { + nodes { + ...IssueNode + } + } + } + } + } + } +} diff --git a/app/assets/javascripts/boards/queries/project_lists_issues.query.graphql b/app/assets/javascripts/boards/queries/project_lists_issues.query.graphql deleted file mode 100644 index 149b76848ef..00000000000 --- a/app/assets/javascripts/boards/queries/project_lists_issues.query.graphql +++ /dev/null @@ -1,18 +0,0 @@ -#import "./issue.fragment.graphql" - -query ProjectListIssues($fullPath: ID!, $boardId: ID!) { - project(fullPath: $fullPath) { - board(id: $boardId) { - lists { - nodes { - id - issues { - nodes { - ...IssueNode - } - } - } - } - } - } -} diff --git a/app/assets/javascripts/boards/stores/actions.js b/app/assets/javascripts/boards/stores/actions.js index 25747788cc9..4e808c809fb 100644 --- a/app/assets/javascripts/boards/stores/actions.js +++ b/app/assets/javascripts/boards/stores/actions.js @@ -1,5 +1,5 @@ import Cookies from 'js-cookie'; -import { sortBy } from 'lodash'; +import { sortBy, pick } from 'lodash'; import createFlash from '~/flash'; import { __ } from '~/locale'; import { parseBoolean } from '~/lib/utils/common_utils'; @@ -10,8 +10,7 @@ import * as types from './mutation_types'; import { formatListIssues, fullBoardId } from '../boards_util'; import boardStore from '~/boards/stores/boards_store'; -import groupListsIssuesQuery from '../queries/group_lists_issues.query.graphql'; -import projectListsIssuesQuery from '../queries/project_lists_issues.query.graphql'; +import listsIssuesQuery from '../queries/lists_issues.query.graphql'; import projectBoardQuery from '../queries/project_board.query.graphql'; import groupBoardQuery from '../queries/group_board.query.graphql'; import createBoardListMutation from '../queries/board_list_create.mutation.graphql'; @@ -38,7 +37,14 @@ export default { }, setFilters: ({ commit }, filters) => { - const { scope, utf8, state, ...filterParams } = filters; + const filterParams = pick(filters, [ + 'assigneeUsername', + 'authorUsername', + 'labelName', + 'milestoneTitle', + 'releaseTag', + 'search', + ]); commit(types.SET_FILTERS, filterParams); }, @@ -197,19 +203,20 @@ export default { fetchIssuesForAllLists: ({ state, commit }) => { commit(types.REQUEST_ISSUES_FOR_ALL_LISTS); - const { endpoints, boardType } = state; + const { endpoints, boardType, filterParams } = state; const { fullPath, boardId } = endpoints; - const query = boardType === BoardType.group ? groupListsIssuesQuery : projectListsIssuesQuery; - const variables = { fullPath, boardId: fullBoardId(boardId), + filters: filterParams, + isGroup: boardType === BoardType.group, + isProject: boardType === BoardType.project, }; return gqlClient .query({ - query, + query: listsIssuesQuery, variables, }) .then(({ data }) => { diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 92c307ebe00..2ef0feaa2af 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -24,6 +24,7 @@ import { deprecatedCreateFlash as Flash, removeFlashClickListener } from './flas import initTodoToggle from './header'; import initImporterStatus from './importer_status'; import initLayoutNav from './layout_nav'; +import initAlertHandler from './alert_handler'; import './feature_highlight/feature_highlight_options'; import LazyLoader from './lazy_loader'; import initLogoAnimation from './logo'; @@ -167,6 +168,7 @@ document.addEventListener('DOMContentLoaded', () => { initUserTracking(); initLayoutNav(); + initAlertHandler(); // Set the default path for all cookies to GitLab's root directory Cookies.defaults.path = gon.relative_url_root || '/'; diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index 11121b2638a..0a8941abe78 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -252,7 +252,8 @@ } } - .cross-project-reference { + .cross-project-reference, + .sidebar-mr-source-branch { color: inherit; span { @@ -389,7 +390,8 @@ border-bottom: 0; overflow: hidden; - &:hover { + &.with-sub-blocks .sub-block:hover, + &:not(.with-sub-blocks):hover { background-color: $gray-100; } diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 5f9a7fda02a..3e53fb96362 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -234,8 +234,7 @@ class IssuableFinder end def attempt_project_search_optimizations? - params[:attempt_project_search_optimizations] && - Feature.enabled?(:attempt_project_search_optimizations, default_enabled: true) + params[:attempt_project_search_optimizations] end def count_key(value) diff --git a/app/models/concerns/timebox.rb b/app/models/concerns/timebox.rb index 8927e42dd97..3e2cf9031d0 100644 --- a/app/models/concerns/timebox.rb +++ b/app/models/concerns/timebox.rb @@ -75,8 +75,8 @@ module Timebox scope :within_timeframe, -> (start_date, end_date) do where('start_date is not NULL or due_date is not NULL') - .where('start_date is NULL or start_date <= ?', end_date) - .where('due_date is NULL or due_date >= ?', start_date) + .where('start_date is NULL or start_date <= ?', end_date) + .where('due_date is NULL or due_date >= ?', start_date) end strip_attributes :title @@ -195,6 +195,10 @@ module Timebox end end + def weight_available? + resource_parent&.feature_available?(:issue_weights) + end + private def timebox_format_reference(format = :iid) diff --git a/app/views/projects/merge_requests/conflicts/show.html.haml b/app/views/projects/merge_requests/conflicts/show.html.haml index 6c23661fb86..28ba2b6ac75 100644 --- a/app/views/projects/merge_requests/conflicts/show.html.haml +++ b/app/views/projects/merge_requests/conflicts/show.html.haml @@ -6,7 +6,7 @@ .merge-request-details.issuable-details = render "projects/merge_requests/mr_box" -= render 'shared/issuable/sidebar', issuable_sidebar: @issuable_sidebar, assignees: @merge_request.assignees += render 'shared/issuable/sidebar', issuable_sidebar: @issuable_sidebar, assignees: @merge_request.assignees, source_branch: @merge_request.source_branch #conflicts{ "v-cloak" => "true", data: { conflicts_path: conflicts_project_merge_request_path(@merge_request.project, @merge_request, format: :json), resolve_conflicts_path: resolve_conflicts_project_merge_request_path(@merge_request.project, @merge_request) } } diff --git a/app/views/projects/merge_requests/show.html.haml b/app/views/projects/merge_requests/show.html.haml index 735a7fa4fea..5ef4929fee0 100644 --- a/app/views/projects/merge_requests/show.html.haml +++ b/app/views/projects/merge_requests/show.html.haml @@ -89,7 +89,7 @@ .loading.hide .spinner.spinner-md -= render 'shared/issuable/sidebar', issuable_sidebar: @issuable_sidebar, assignees: @merge_request.assignees += render 'shared/issuable/sidebar', issuable_sidebar: @issuable_sidebar, assignees: @merge_request.assignees, source_branch: @merge_request.source_branch - if @merge_request.can_be_reverted?(current_user) = render "projects/commit/change", type: 'revert', commit: @merge_request.merge_commit, title: @merge_request.title diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index b336ab3eb00..44d776e4771 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -151,15 +151,24 @@ .js-sidebar-subscriptions-entry-point - project_ref = issuable_sidebar[:reference] - .block.project-reference - .sidebar-collapsed-icon.dont-change-state - = clipboard_button(text: project_ref, title: _('Copy reference'), placement: "left", boundary: 'viewport') - .cross-project-reference.hide-collapsed - %span - = _('Reference:') - %cite{ title: project_ref } - = project_ref - = clipboard_button(text: project_ref, title: _('Copy reference'), placement: "left", boundary: 'viewport') + .block.with-sub-blocks + .project-reference.sub-block + .sidebar-collapsed-icon.dont-change-state + = clipboard_button(text: project_ref, title: _('Copy reference'), placement: "left", boundary: 'viewport') + .cross-project-reference.hide-collapsed + %span + = _('Reference:') + %cite{ title: project_ref } + = project_ref + = clipboard_button(text: project_ref, title: _('Copy reference'), placement: "left", boundary: 'viewport') + - if issuable_type == 'merge_request' + .sidebar-source-branch.sub-block + .sidebar-collapsed-icon.dont-change-state + = clipboard_button(text: source_branch, title: _('Copy branch name'), placement: "left", boundary: 'viewport') + .sidebar-mr-source-branch.hide-collapsed + %span + = _('Source branch: %{source_branch_open}${source_branch}%{source_branch_close}').html_safe % { source_branch_open: "<cite class='ref-name' title='#{source_branch}'>".html_safe, source_branch_close: "</cite>".html_safe, source_branch: source_branch } + = clipboard_button(text: source_branch, title: _('Copy branch name'), placement: "left", boundary: 'viewport') - if issuable_sidebar.dig(:current_user, :can_move) .block.js-sidebar-move-issue-block diff --git a/app/workers/concerns/new_issuable.rb b/app/workers/concerns/new_issuable.rb index 22ba7c97309..482a74f49f7 100644 --- a/app/workers/concerns/new_issuable.rb +++ b/app/workers/concerns/new_issuable.rb @@ -27,6 +27,6 @@ module NewIssuable # rubocop: enable CodeReuse/ActiveRecord def log_error(record_class, record_id) - Rails.logger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error("#{self.class}: couldn't find #{record_class} with ID=#{record_id}, skipping job") end end diff --git a/app/workers/object_storage/migrate_uploads_worker.rb b/app/workers/object_storage/migrate_uploads_worker.rb index 33a0e0f5f88..f489e428e8d 100644 --- a/app/workers/object_storage/migrate_uploads_worker.rb +++ b/app/workers/object_storage/migrate_uploads_worker.rb @@ -41,16 +41,14 @@ module ObjectStorage end end - # rubocop:disable Gitlab/RailsLogger def report!(results) success, failures = results.partition(&:success?) - Rails.logger.info header(success, failures) - Rails.logger.warn failures(failures) + Gitlab::AppLogger.info header(success, failures) + Gitlab::AppLogger.warn failures(failures) raise MigrationFailures.new(failures.map(&:error)) if failures.any? end - # rubocop:enable Gitlab/RailsLogger def header(success, failures) _("Migrated %{success_count}/%{total_count} files.") % { success_count: success.count, total_count: success.count + failures.count } @@ -104,7 +102,7 @@ module ObjectStorage report!(results) rescue SanityCheckError => e # do not retry: the job is insane - Rails.logger.warn "#{self.class}: Sanity check error (#{e.message})" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.warn "#{self.class}: Sanity check error (#{e.message})" end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb index 395fce0696c..af8f3927be0 100644 --- a/app/workers/repository_fork_worker.rb +++ b/app/workers/repository_fork_worker.rb @@ -34,7 +34,7 @@ class RepositoryForkWorker # rubocop:disable Scalability/IdempotentWorker def start_fork(project) return true if start(project.import_state) - Rails.logger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.") # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info("Project #{project.full_path} was in inconsistent state (#{project.import_status}) while forking.") false end diff --git a/app/workers/run_pipeline_schedule_worker.rb b/app/workers/run_pipeline_schedule_worker.rb index 7d76cbed77f..605dd624260 100644 --- a/app/workers/run_pipeline_schedule_worker.rb +++ b/app/workers/run_pipeline_schedule_worker.rb @@ -31,11 +31,10 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker private - # rubocop:disable Gitlab/RailsLogger def error(schedule, error) failed_creation_counter.increment - Rails.logger.error "Failed to create a scheduled pipeline. " \ + Gitlab::AppLogger.error "Failed to create a scheduled pipeline. " \ "schedule_id: #{schedule.id} message: #{error.message}" Gitlab::ErrorTracking @@ -43,7 +42,6 @@ class RunPipelineScheduleWorker # rubocop:disable Scalability/IdempotentWorker issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/41231', schedule_id: schedule.id) end - # rubocop:enable Gitlab/RailsLogger def failed_creation_counter @failed_creation_counter ||= diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb index b3b1ed66efc..f8209ae5e63 100644 --- a/app/workers/stuck_ci_jobs_worker.rb +++ b/app/workers/stuck_ci_jobs_worker.rb @@ -17,7 +17,7 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker def perform return unless try_obtain_lease - Rails.logger.info "#{self.class}: Cleaning stuck builds" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info "#{self.class}: Cleaning stuck builds" # rubocop:disable Gitlab/RailsLogger drop :running, BUILD_RUNNING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure drop :pending, BUILD_PENDING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure @@ -69,7 +69,7 @@ class StuckCiJobsWorker # rubocop:disable Scalability/IdempotentWorker # rubocop: enable CodeReuse/ActiveRecord def drop_build(type, build, status, timeout, reason) - Rails.logger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout}, reason: #{reason})" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info "#{self.class}: Dropping #{type} build #{build.id} for runner #{build.runner_id} (status: #{status}, timeout: #{timeout}, reason: #{reason})" Gitlab::OptimisticLocking.retry_lock(build, 3) do |b| b.drop(reason) end diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb index e0209b8237a..0f9b4ddb980 100644 --- a/app/workers/stuck_merge_jobs_worker.rb +++ b/app/workers/stuck_merge_jobs_worker.rb @@ -7,7 +7,7 @@ class StuckMergeJobsWorker # rubocop:disable Scalability/IdempotentWorker feature_category :source_code_management def self.logger - Rails.logger # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger end # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/workers/trending_projects_worker.rb b/app/workers/trending_projects_worker.rb index ee7724e0fa8..eb1a7f4fef9 100644 --- a/app/workers/trending_projects_worker.rb +++ b/app/workers/trending_projects_worker.rb @@ -11,7 +11,7 @@ class TrendingProjectsWorker # rubocop:disable Scalability/IdempotentWorker feature_category :source_code_management def perform - Rails.logger.info('Refreshing trending projects') # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info('Refreshing trending projects') TrendingProject.refresh! end diff --git a/app/workers/upload_checksum_worker.rb b/app/workers/upload_checksum_worker.rb index dc2511f718c..ce43b56bbd8 100644 --- a/app/workers/upload_checksum_worker.rb +++ b/app/workers/upload_checksum_worker.rb @@ -10,6 +10,6 @@ class UploadChecksumWorker # rubocop:disable Scalability/IdempotentWorker upload.calculate_checksum! upload.save! rescue ActiveRecord::RecordNotFound - Rails.logger.error("UploadChecksumWorker: couldn't find upload #{upload_id}, skipping") # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error("UploadChecksumWorker: couldn't find upload #{upload_id}, skipping") end end diff --git a/changelogs/unreleased/229046-iterations-charts-refactoring.yml b/changelogs/unreleased/229046-iterations-charts-refactoring.yml new file mode 100644 index 00000000000..8b1ccd1ba4a --- /dev/null +++ b/changelogs/unreleased/229046-iterations-charts-refactoring.yml @@ -0,0 +1,5 @@ +--- +title: Add index to resource_iteration_events for add actions +merge_request: 41280 +author: +type: other diff --git a/changelogs/unreleased/23767-add-branch-to-mr-sidebar.yml b/changelogs/unreleased/23767-add-branch-to-mr-sidebar.yml new file mode 100644 index 00000000000..a42c3c204c2 --- /dev/null +++ b/changelogs/unreleased/23767-add-branch-to-mr-sidebar.yml @@ -0,0 +1,5 @@ +--- +title: Display Merge Request's source branch name in sidebar +merge_request: 34901 +author: Ethan Reesor (@firelizzard) +type: added diff --git a/changelogs/unreleased/alert-handler.yml b/changelogs/unreleased/alert-handler.yml new file mode 100644 index 00000000000..5907fa30b2a --- /dev/null +++ b/changelogs/unreleased/alert-handler.yml @@ -0,0 +1,5 @@ +--- +title: Adds an alert handler for bootstrap migration +merge_request: 41323 +author: +type: other diff --git a/changelogs/unreleased/app-logger-1.yml b/changelogs/unreleased/app-logger-1.yml new file mode 100644 index 00000000000..778a0612bd4 --- /dev/null +++ b/changelogs/unreleased/app-logger-1.yml @@ -0,0 +1,5 @@ +--- +title: Use applogger in app/workers/* +merge_request: 41046 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/app-logger-12.yml b/changelogs/unreleased/app-logger-12.yml new file mode 100644 index 00000000000..eb9542ebc9a --- /dev/null +++ b/changelogs/unreleased/app-logger-12.yml @@ -0,0 +1,5 @@ +--- +title: Use applogger in lib/gitlab +merge_request: 41063 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/app-logger-13.yml b/changelogs/unreleased/app-logger-13.yml new file mode 100644 index 00000000000..74e93b08b1d --- /dev/null +++ b/changelogs/unreleased/app-logger-13.yml @@ -0,0 +1,5 @@ +--- +title: Use applogger in lib/gitlab/database +merge_request: 41068 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/app-logger-15.yml b/changelogs/unreleased/app-logger-15.yml new file mode 100644 index 00000000000..b991d64493f --- /dev/null +++ b/changelogs/unreleased/app-logger-15.yml @@ -0,0 +1,5 @@ +--- +title: Use applogger in lib/gitlab/ +merge_request: 41075 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/app-logger-3.yml b/changelogs/unreleased/app-logger-3.yml new file mode 100644 index 00000000000..acb32aefbe3 --- /dev/null +++ b/changelogs/unreleased/app-logger-3.yml @@ -0,0 +1,5 @@ +--- +title: Use applogger in ee/app/models, helpers and workers +merge_request: 41048 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/app-logger-8.yml b/changelogs/unreleased/app-logger-8.yml new file mode 100644 index 00000000000..94ee44188a8 --- /dev/null +++ b/changelogs/unreleased/app-logger-8.yml @@ -0,0 +1,5 @@ +--- +title: Use applogger +merge_request: 41055 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/gaga5lala-remove-feature-flag.yml b/changelogs/unreleased/gaga5lala-remove-feature-flag.yml new file mode 100644 index 00000000000..b13ddbb978c --- /dev/null +++ b/changelogs/unreleased/gaga5lala-remove-feature-flag.yml @@ -0,0 +1,5 @@ +--- +title: Remove attempt_project_search_optimizations feature flag +merge_request: 41550 +author: gaga5lala +type: other diff --git a/changelogs/unreleased/rails-save-bang-29.yml b/changelogs/unreleased/rails-save-bang-29.yml new file mode 100644 index 00000000000..f3735f4a473 --- /dev/null +++ b/changelogs/unreleased/rails-save-bang-29.yml @@ -0,0 +1,5 @@ +--- +title: Fix Rails/SaveBang offenses for 3 files +merge_request: 41392 +author: Rajendra Kadam +type: other diff --git a/changelogs/unreleased/rails-save-bang-31.yml b/changelogs/unreleased/rails-save-bang-31.yml new file mode 100644 index 00000000000..87cf48447a1 --- /dev/null +++ b/changelogs/unreleased/rails-save-bang-31.yml @@ -0,0 +1,5 @@ +--- +title: Fix Rails/SaveBang offenses for 3 files +merge_request: 41395 +author: Rajendra Kadam +type: other diff --git a/danger/pajamas/Dangerfile b/danger/pajamas/Dangerfile new file mode 100644 index 00000000000..34dcbc21941 --- /dev/null +++ b/danger/pajamas/Dangerfile @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +PATTERNS = %w[ + createFlash + gl-deprecated-button + loading-button + pagination-button + gl-deprecated-dropdown + gl-deprecated-dropdown-divider + gl-deprecated-dropdown-header + gl-deprecated-dropdown-item + initDeprecatedJQueryDropdown +].freeze + +def get_added_lines(files) + lines = [] + files.each do |file| + lines += helper.changed_lines(file).select { |line| %r{^[+]}.match?(line) } + end + lines +end + +changed_vue_haml_files = helper.changed_files(/.vue$|.haml$/) + +return if changed_vue_haml_files.empty? + +changed_lines_in_mr = get_added_lines(changed_vue_haml_files) +has_deprecated_components = changed_lines_in_mr.select { |i| i[/#{PATTERNS.join("|")}/] } +deprecated_components_in_mr = PATTERNS.select { |s| has_deprecated_components.join(" ")[s] } + +return if deprecated_components_in_mr.empty? + +warn "This merge request contains deprecated components. Please consider using Pajamas components instead." + +markdown(<<~MARKDOWN) + ## Deprecated components + + The following components are deprecated: + + * #{deprecated_components_in_mr.join("\n* ")} + + Please consider using [Pajamas components](https://design.gitlab.com/components/status/) instead. +MARKDOWN diff --git a/danger/specialization_labels/Dangerfile b/danger/specialization_labels/Dangerfile index b12771b9807..919f7313b49 100644 --- a/danger/specialization_labels/Dangerfile +++ b/danger/specialization_labels/Dangerfile @@ -14,8 +14,9 @@ SPECIALIZATIONS = { }.freeze labels_to_add = helper.changes_by_category.each_with_object([]) do |(category, _changes), memo| - label = SPECIALIZATIONS.fetch(category, category.to_s) - memo << label unless gitlab.mr_labels.include?(label) + label = SPECIALIZATIONS[category] + + memo << label if label && !gitlab.mr_labels.include?(label) end if labels_to_add.any? diff --git a/db/migrate/20200903092241_add_index_to_resource_iteration_events_add_events.rb b/db/migrate/20200903092241_add_index_to_resource_iteration_events_add_events.rb new file mode 100644 index 00000000000..be530f1f9b5 --- /dev/null +++ b/db/migrate/20200903092241_add_index_to_resource_iteration_events_add_events.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddIndexToResourceIterationEventsAddEvents < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + INDEX_NAME = 'index_resource_iteration_events_on_iteration_id_and_add_action' + ADD_ACTION = '1' + + def up + # Index add iteration events + add_concurrent_index :resource_iteration_events, :iteration_id, where: "action = #{ADD_ACTION}", name: INDEX_NAME + end + + def down + remove_concurrent_index :resource_iteration_events, :iteration_id, name: INDEX_NAME + end +end diff --git a/db/post_migrate/20200824140259_update_location_fingerprint_for_cs_findings.rb b/db/post_migrate/20200824140259_update_location_fingerprint_for_cs_findings.rb deleted file mode 100644 index d261e713b83..00000000000 --- a/db/post_migrate/20200824140259_update_location_fingerprint_for_cs_findings.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class UpdateLocationFingerprintForCsFindings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - BATCH_SIZE = 1_000 - INTERVAL = 2.minutes - - # 815_565 records - def up - # no-op - # There was a bug introduced with this migration for gitlab.com - # We created new migration to mitigate that VERISON=20200907123723 - # and change this one to no-op to prevent running migration twice - end - - def down - # no-op - # intentionally blank - end -end diff --git a/db/post_migrate/20200907123723_fix_update_location_fingerprint_for_cs_findings.rb b/db/post_migrate/20200907123723_fix_update_location_fingerprint_for_cs_findings.rb deleted file mode 100644 index 064ee64f3af..00000000000 --- a/db/post_migrate/20200907123723_fix_update_location_fingerprint_for_cs_findings.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true - -class FixUpdateLocationFingerprintForCsFindings < ActiveRecord::Migration[6.0] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - - disable_ddl_transaction! - - BATCH_SIZE = 1_000 - INTERVAL = 2.minutes - - # 815_565 records - def up - return unless Gitlab.ee? - - migration = Gitlab::BackgroundMigration::UpdateLocationFingerprintForCsFindings - migration_name = migration.to_s.demodulize - - Gitlab::BackgroundMigration.steal(migration_name) - - relation = migration::Finding.container_scanning - queue_background_migration_jobs_by_range_at_intervals(relation, - migration_name, - INTERVAL, - batch_size: BATCH_SIZE) - end - - def down - # no-op - # intentionally blank - end -end diff --git a/db/schema_migrations/20200824140259 b/db/schema_migrations/20200824140259 deleted file mode 100644 index 4c25ec5409b..00000000000 --- a/db/schema_migrations/20200824140259 +++ /dev/null @@ -1 +0,0 @@ -e24f8495b7458ce57e148017ef6cae901e7f3997fca247afeff524a43e739431
\ No newline at end of file diff --git a/db/schema_migrations/20200903092241 b/db/schema_migrations/20200903092241 new file mode 100644 index 00000000000..bedd97c3918 --- /dev/null +++ b/db/schema_migrations/20200903092241 @@ -0,0 +1 @@ +e6c3d5352feed1adc82b14218a6f47fa55df9e0add8a59228d128e4e7f39614b
\ No newline at end of file diff --git a/db/schema_migrations/20200907123723 b/db/schema_migrations/20200907123723 deleted file mode 100644 index 1a6288ee6c9..00000000000 --- a/db/schema_migrations/20200907123723 +++ /dev/null @@ -1 +0,0 @@ -74f6adf29b9293537d653b993ab0e2f31af2ab5a8581ca631e8a87fc589ca284
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 3ef216a5667..52cf480c2fa 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -20817,6 +20817,8 @@ CREATE INDEX index_resource_iteration_events_on_merge_request_id ON public.resou CREATE INDEX index_resource_iteration_events_on_user_id ON public.resource_iteration_events USING btree (user_id); +CREATE INDEX index_resource_iterationn_events_on_iteration_id_and_add_action ON public.resource_iteration_events USING btree (iteration_id) WHERE (action = 1); + CREATE INDEX index_resource_label_events_issue_id_label_id_action ON public.resource_label_events USING btree (issue_id, label_id, action); CREATE INDEX index_resource_label_events_on_epic_id ON public.resource_label_events USING btree (epic_id); diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 246f5d2992a..6a8bbc5635d 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -1922,7 +1922,9 @@ test: ``` The following example will skip the `build` job if a change is detected in any file -in the root directory of the repository with a `.md` extension: +in the root directory of the repository with a `.md` extension. This mean that if you change multiple files, +but only one file is a `.md` file, the `build` job will still be skipped and will +not run for the other files. ```yaml build: diff --git a/lib/gitlab/background_migration/calculate_wiki_sizes.rb b/lib/gitlab/background_migration/calculate_wiki_sizes.rb index e62f5edd0e7..76598f6e2a6 100644 --- a/lib/gitlab/background_migration/calculate_wiki_sizes.rb +++ b/lib/gitlab/background_migration/calculate_wiki_sizes.rb @@ -10,7 +10,7 @@ module Gitlab .includes(project: [:route, :group, namespace: [:owner]]).find_each do |statistics| statistics.refresh!(only: [:wiki_size]) rescue => e - Rails.logger.error "Failed to update wiki statistics. id: #{statistics.id} message: #{e.message}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error "Failed to update wiki statistics. id: #{statistics.id} message: #{e.message}" end end end diff --git a/lib/gitlab/background_migration/fill_valid_time_for_pages_domain_certificate.rb b/lib/gitlab/background_migration/fill_valid_time_for_pages_domain_certificate.rb index 4016b807f21..c0099d44b5a 100644 --- a/lib/gitlab/background_migration/fill_valid_time_for_pages_domain_certificate.rb +++ b/lib/gitlab/background_migration/fill_valid_time_for_pages_domain_certificate.rb @@ -25,7 +25,7 @@ module Gitlab certificate_valid_not_after: domain.x509&.not_after&.iso8601 ) rescue => e - Rails.logger.error "Failed to update pages domain certificate valid time. id: #{domain.id}, message: #{e.message}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error "Failed to update pages domain certificate valid time. id: #{domain.id}, message: #{e.message}" end end end diff --git a/lib/gitlab/background_migration/update_location_fingerprint_for_cs_findings.rb b/lib/gitlab/background_migration/update_location_fingerprint_for_cs_findings.rb deleted file mode 100644 index 7e6284a2a18..00000000000 --- a/lib/gitlab/background_migration/update_location_fingerprint_for_cs_findings.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true -# rubocop:disable Style/Documentation - -module Gitlab - module BackgroundMigration - class UpdateLocationFingerprintForCsFindings - def perform(start_id, stop_id) - end - end - end -end - -Gitlab::BackgroundMigration::UpdateLocationFingerprintForCsFindings.prepend_if_ee('EE::Gitlab::BackgroundMigration::UpdateLocationFingerprintForCsFindings') diff --git a/lib/gitlab/cleanup/orphan_job_artifact_files.rb b/lib/gitlab/cleanup/orphan_job_artifact_files.rb index 017adc7be4a..6d18f9070cc 100644 --- a/lib/gitlab/cleanup/orphan_job_artifact_files.rb +++ b/lib/gitlab/cleanup/orphan_job_artifact_files.rb @@ -18,7 +18,7 @@ module Gitlab @limit = limit @dry_run = dry_run @niceness = (niceness || DEFAULT_NICENESS).downcase - @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger + @logger = logger || Gitlab::AppLogger @total_found = @total_cleaned = 0 new_batch! diff --git a/lib/gitlab/cleanup/orphan_job_artifact_files_batch.rb b/lib/gitlab/cleanup/orphan_job_artifact_files_batch.rb index 6ad05c7b2e4..4b1d16eb974 100644 --- a/lib/gitlab/cleanup/orphan_job_artifact_files_batch.rb +++ b/lib/gitlab/cleanup/orphan_job_artifact_files_batch.rb @@ -22,7 +22,7 @@ module Gitlab attr_reader :batch_size, :dry_run attr_accessor :artifact_files - def initialize(batch_size:, dry_run: true, logger: Rails.logger) # rubocop:disable Gitlab/RailsLogger + def initialize(batch_size:, dry_run: true, logger: Gitlab::AppLogger) @batch_size = batch_size @dry_run = dry_run @logger = logger diff --git a/lib/gitlab/cleanup/orphan_lfs_file_references.rb b/lib/gitlab/cleanup/orphan_lfs_file_references.rb index 6710b0bba66..14eac474e27 100644 --- a/lib/gitlab/cleanup/orphan_lfs_file_references.rb +++ b/lib/gitlab/cleanup/orphan_lfs_file_references.rb @@ -12,7 +12,7 @@ module Gitlab def initialize(project, dry_run: true, logger: nil, limit: nil) @project = project @dry_run = dry_run - @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger + @logger = logger || Gitlab::AppLogger @limit = limit end diff --git a/lib/gitlab/cleanup/project_upload_file_finder.rb b/lib/gitlab/cleanup/project_upload_file_finder.rb index 3d35d474f5d..0f40f683354 100644 --- a/lib/gitlab/cleanup/project_upload_file_finder.rb +++ b/lib/gitlab/cleanup/project_upload_file_finder.rb @@ -49,7 +49,7 @@ module Gitlab cmd = %W[#{ionice} -c Idle] + cmd if ionice log_msg = "find command: \"#{cmd.join(' ')}\"" - Rails.logger.info log_msg # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info log_msg cmd end diff --git a/lib/gitlab/cleanup/project_uploads.rb b/lib/gitlab/cleanup/project_uploads.rb index 056e075cb21..77231665e7e 100644 --- a/lib/gitlab/cleanup/project_uploads.rb +++ b/lib/gitlab/cleanup/project_uploads.rb @@ -8,7 +8,7 @@ module Gitlab attr_reader :logger def initialize(logger: nil) - @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger + @logger = logger || Gitlab::AppLogger end def run!(dry_run: true) diff --git a/lib/gitlab/cleanup/remote_uploads.rb b/lib/gitlab/cleanup/remote_uploads.rb index 42c93b7aecb..6cadb9424f7 100644 --- a/lib/gitlab/cleanup/remote_uploads.rb +++ b/lib/gitlab/cleanup/remote_uploads.rb @@ -7,7 +7,7 @@ module Gitlab BATCH_SIZE = 100 def initialize(logger: nil) - @logger = logger || Rails.logger # rubocop:disable Gitlab/RailsLogger + @logger = logger || Gitlab::AppLogger end def run!(dry_run: false) diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb index b62b6e20dd5..6f66ed0df14 100644 --- a/lib/gitlab/database/migration_helpers.rb +++ b/lib/gitlab/database/migration_helpers.rb @@ -87,7 +87,7 @@ module Gitlab options = options.merge({ algorithm: :concurrently }) if index_exists?(table_name, column_name, options) - Rails.logger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.warn "Index not created because it already exists (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" return end @@ -113,7 +113,7 @@ module Gitlab options = options.merge({ algorithm: :concurrently }) unless index_exists?(table_name, column_name, options) - Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, column_name: #{column_name}" return end @@ -143,7 +143,7 @@ module Gitlab options = options.merge({ algorithm: :concurrently }) unless index_exists_by_name?(table_name, index_name) - Rails.logger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, index_name: #{index_name}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.warn "Index not removed because it does not exist (this may be due to an aborted migration or similar): table_name: #{table_name}, index_name: #{index_name}" return end @@ -163,7 +163,6 @@ module Gitlab # defaults to "CASCADE". # name - The name of the foreign key. # - # rubocop:disable Gitlab/RailsLogger def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil, validate: true) # Transactions would result in ALTER TABLE locks being held for the # duration of the transaction, defeating the purpose of this method. @@ -183,7 +182,7 @@ module Gitlab "source: #{source}, target: #{target}, column: #{options[:column]}, "\ "name: #{options[:name]}, on_delete: #{options[:on_delete]}" - Rails.logger.warn warning_message + Gitlab::AppLogger.warn warning_message else # Using NOT VALID allows us to create a key without immediately # validating it. This means we keep the ALTER TABLE lock only for a @@ -217,7 +216,6 @@ module Gitlab end end end - # rubocop:enable Gitlab/RailsLogger def validate_foreign_key(source, column, name: nil) fk_name = name || concurrent_foreign_key_name(source, column) @@ -1085,7 +1083,6 @@ into similar problems in the future (e.g. when new tables are created). # Should be unique per table (not per column) # validate - Whether to validate the constraint in this call # - # rubocop:disable Gitlab/RailsLogger def add_check_constraint(table, check, constraint_name, validate: true) validate_check_constraint_name!(constraint_name) @@ -1102,7 +1099,7 @@ into similar problems in the future (e.g. when new tables are created). table: #{table}, check: #{check}, constraint name: #{constraint_name} MESSAGE - Rails.logger.warn warning_message + Gitlab::AppLogger.warn warning_message else # Only add the constraint without validating it # Even though it is fast, ADD CONSTRAINT requires an EXCLUSIVE lock @@ -1187,7 +1184,7 @@ into similar problems in the future (e.g. when new tables are created). column #{table}.#{column} is already defined as `NOT NULL` MESSAGE - Rails.logger.warn warning_message + Gitlab::AppLogger.warn warning_message end end diff --git a/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers.rb b/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers.rb index 1fb9476b7d9..2def3a4d3a9 100644 --- a/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers.rb +++ b/lib/gitlab/database/partitioning_migration_helpers/foreign_key_helpers.rb @@ -31,7 +31,7 @@ module Gitlab current_keys << specified_key else - Rails.logger.warn "foreign key not added because it already exists: #{specified_key}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.warn "foreign key not added because it already exists: #{specified_key}" current_keys end end @@ -56,7 +56,7 @@ module Gitlab existing_key.delete current_keys.delete(existing_key) else - Rails.logger.warn "foreign key not removed because it doesn't exist: #{specified_key}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.warn "foreign key not removed because it doesn't exist: #{specified_key}" end current_keys diff --git a/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb b/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb index 04c63d27f9e..ce39db4a2ec 100644 --- a/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb +++ b/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers.rb @@ -202,10 +202,8 @@ module Gitlab def create_range_partitioned_copy(source_table_name, partitioned_table_name, partition_column, primary_key) if table_exists?(partitioned_table_name) - # rubocop:disable Gitlab/RailsLogger - Rails.logger.warn "Partitioned table not created because it already exists" \ + Gitlab::AppLogger.warn "Partitioned table not created because it already exists" \ " (this may be due to an aborted migration or similar): table_name: #{partitioned_table_name} " - # rubocop:enable Gitlab/RailsLogger return end @@ -258,10 +256,8 @@ module Gitlab def create_range_partition_safely(partition_name, table_name, lower_bound, upper_bound) if table_exists?(table_for_range_partition(partition_name)) - # rubocop:disable Gitlab/RailsLogger - Rails.logger.warn "Partition not created because it already exists" \ + Gitlab::AppLogger.warn "Partition not created because it already exists" \ " (this may be due to an aborted migration or similar): partition_name: #{partition_name}" - # rubocop:enable Gitlab/RailsLogger return end @@ -282,10 +278,8 @@ module Gitlab def create_sync_function(name, partitioned_table_name, unique_key) if function_exists?(name) - # rubocop:disable Gitlab/RailsLogger - Rails.logger.warn "Partitioning sync function not created because it already exists" \ + Gitlab::AppLogger.warn "Partitioning sync function not created because it already exists" \ " (this may be due to an aborted migration or similar): function name: #{name}" - # rubocop:enable Gitlab/RailsLogger return end @@ -317,10 +311,8 @@ module Gitlab def create_sync_trigger(table_name, trigger_name, function_name) if trigger_exists?(table_name, trigger_name) - # rubocop:disable Gitlab/RailsLogger - Rails.logger.warn "Partitioning sync trigger not created because it already exists" \ + Gitlab::AppLogger.warn "Partitioning sync trigger not created because it already exists" \ " (this may be due to an aborted migration or similar): trigger name: #{trigger_name}" - # rubocop:enable Gitlab/RailsLogger return end diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb index 4fbbfdc4914..562e651cabc 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb @@ -71,7 +71,7 @@ module Gitlab unless gitlab_shell.mv_namespace(repository_storage, old_full_path, new_full_path) message = "Exception moving on shard #{repository_storage} from #{old_full_path} to #{new_full_path}" - Rails.logger.error message # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error message end end end diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb index 8b92b296408..5dbf30bad4e 100644 --- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb +++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb @@ -56,7 +56,7 @@ module Gitlab unless gitlab_shell.mv_repository(project.repository_storage, old_path, new_path) - Rails.logger.error "Error moving #{old_path} to #{new_path}" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error "Error moving #{old_path} to #{new_path}" end end diff --git a/lib/gitlab/metrics/samplers/puma_sampler.rb b/lib/gitlab/metrics/samplers/puma_sampler.rb index b5343d5e66a..d295beb59f1 100644 --- a/lib/gitlab/metrics/samplers/puma_sampler.rb +++ b/lib/gitlab/metrics/samplers/puma_sampler.rb @@ -42,7 +42,7 @@ module Gitlab def puma_stats Puma.stats rescue NoMethodError - Rails.logger.info "PumaSampler: stats are not available yet, waiting for Puma to boot" # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info "PumaSampler: stats are not available yet, waiting for Puma to boot" nil end diff --git a/lib/gitlab/middleware/read_only/controller.rb b/lib/gitlab/middleware/read_only/controller.rb index 6573506e926..cfea4aaddf3 100644 --- a/lib/gitlab/middleware/read_only/controller.rb +++ b/lib/gitlab/middleware/read_only/controller.rb @@ -36,7 +36,7 @@ module Gitlab def call if disallowed_request? && Gitlab::Database.read_only? - Rails.logger.debug('GitLab ReadOnly: preventing possible non read-only operation') # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.debug('GitLab ReadOnly: preventing possible non read-only operation') if json_request? return [403, { 'Content-Type' => APPLICATION_JSON }, [{ 'message' => ERROR_MESSAGE }.to_json]] diff --git a/lib/gitlab/sanitizers/exif.rb b/lib/gitlab/sanitizers/exif.rb index 7e22bf4d7df..78c517c49d8 100644 --- a/lib/gitlab/sanitizers/exif.rb +++ b/lib/gitlab/sanitizers/exif.rb @@ -48,7 +48,7 @@ module Gitlab attr_reader :logger - def initialize(logger: Rails.logger) # rubocop:disable Gitlab/RailsLogger + def initialize(logger: Gitlab::AppLogger) @logger = logger end diff --git a/lib/gitlab_danger.rb b/lib/gitlab_danger.rb index 5537bd81f10..a906beda80e 100644 --- a/lib/gitlab_danger.rb +++ b/lib/gitlab_danger.rb @@ -13,6 +13,7 @@ class GitlabDanger commit_messages telemetry utility_css + pajamas ].freeze CI_ONLY_RULES ||= %w[ diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index ccdd1443fb0..b349b46dc18 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -41,7 +41,7 @@ module Mattermost begin yield self rescue Errno::ECONNREFUSED => e - Rails.logger.error(e.message + "\n" + e.backtrace.join("\n")) # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.error(e.message + "\n" + e.backtrace.join("\n")) raise Mattermost::NoSessionError ensure destroy diff --git a/lib/microsoft_teams/notifier.rb b/lib/microsoft_teams/notifier.rb index 096e1e2ee96..0b21c355a54 100644 --- a/lib/microsoft_teams/notifier.rb +++ b/lib/microsoft_teams/notifier.rb @@ -19,7 +19,7 @@ module MicrosoftTeams result = true if response rescue Gitlab::HTTP::Error, StandardError => error - Rails.logger.info("#{self.class.name}: Error while connecting to #{@webhook}: #{error.message}") # rubocop:disable Gitlab/RailsLogger + Gitlab::AppLogger.info("#{self.class.name}: Error while connecting to #{@webhook}: #{error.message}") end result diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 1179805e8ed..b7a2efd2710 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -452,7 +452,7 @@ msgstr "" msgid "%{issuableType} will be removed! Are you sure?" msgstr "" -msgid "%{issuesSize} issues with a limit of %{maxIssueCount}" +msgid "%{issuesCount} issues with a limit of %{maxIssueCount}" msgstr "" msgid "%{issuesSize} with a limit of %{maxIssueCount}" @@ -773,6 +773,12 @@ msgstr "" msgid "%{timebox_name} should belong either to a project or a group." msgstr "" +msgid "%{timebox_type} does not support burnup charts" +msgstr "" + +msgid "%{timebox_type} must have a start and due date" +msgstr "" + msgid "%{title} %{operator} %{threshold}" msgstr "" @@ -15857,18 +15863,12 @@ msgid_plural "Milestones" msgstr[0] "" msgstr[1] "" -msgid "Milestone does not support burnup charts" -msgstr "" - msgid "Milestone lists not available with your current license" msgstr "" msgid "Milestone lists show all issues from the selected milestone." msgstr "" -msgid "Milestone must have a start and due date" -msgstr "" - msgid "MilestoneSidebar|Closed:" msgstr "" @@ -23484,6 +23484,9 @@ msgstr "" msgid "Source (branch or tag)" msgstr "" +msgid "Source branch: %{source_branch_open}${source_branch}%{source_branch_close}" +msgstr "" + msgid "Source code" msgstr "" diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 303bfc59f61..28764f98fe1 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -1004,36 +1004,22 @@ RSpec.describe IssuesFinder do end end - context 'when attempt_group_search_optimizations is unset and attempt_project_search_optimizations is set' do - let(:params) { { search: 'foo', attempt_project_search_optimizations: true } } - - context 'and the corresponding feature flag is disabled' do - before do - stub_feature_flags(attempt_project_search_optimizations: false) - end + context 'when all conditions are met' do + context "uses group search optimization" do + let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } - it 'returns false' do - expect(finder.use_cte_for_search?).to be_falsey + it 'returns true' do + expect(finder.use_cte_for_search?).to be_truthy end end - context 'and the corresponding feature flag is enabled' do - before do - stub_feature_flags(attempt_project_search_optimizations: true) - end + context "uses project search optimization" do + let(:params) { { search: 'foo', attempt_project_search_optimizations: true } } it 'returns true' do expect(finder.use_cte_for_search?).to be_truthy end end end - - context 'when all conditions are met' do - let(:params) { { search: 'foo', attempt_group_search_optimizations: true } } - - it 'returns true' do - expect(finder.use_cte_for_search?).to be_truthy - end - end end end diff --git a/spec/frontend/alert_handler_spec.js b/spec/frontend/alert_handler_spec.js new file mode 100644 index 00000000000..ba2f4f24aa5 --- /dev/null +++ b/spec/frontend/alert_handler_spec.js @@ -0,0 +1,46 @@ +import { setHTMLFixture } from 'helpers/fixtures'; +import initAlertHandler from '~/alert_handler'; + +describe('Alert Handler', () => { + const ALERT_SELECTOR = 'gl-alert'; + const CLOSE_SELECTOR = 'gl-alert-dismiss'; + const ALERT_HTML = `<div class="${ALERT_SELECTOR}"><button class="${CLOSE_SELECTOR}">Dismiss</button></div>`; + + const findFirstAlert = () => document.querySelector(`.${ALERT_SELECTOR}`); + const findAllAlerts = () => document.querySelectorAll(`.${ALERT_SELECTOR}`); + const findFirstCloseButton = () => document.querySelector(`.${CLOSE_SELECTOR}`); + + describe('initAlertHandler', () => { + describe('with one alert', () => { + beforeEach(() => { + setHTMLFixture(ALERT_HTML); + initAlertHandler(); + }); + + it('should render the alert', () => { + expect(findFirstAlert()).toExist(); + }); + + it('should dismiss the alert on click', () => { + findFirstCloseButton().click(); + expect(findFirstAlert()).not.toExist(); + }); + }); + + describe('with two alerts', () => { + beforeEach(() => { + setHTMLFixture(ALERT_HTML + ALERT_HTML); + initAlertHandler(); + }); + + it('should render two alerts', () => { + expect(findAllAlerts()).toHaveLength(2); + }); + + it('should dismiss only one alert on click', () => { + findFirstCloseButton().click(); + expect(findAllAlerts()).toHaveLength(1); + }); + }); + }); +}); diff --git a/spec/lib/gitlab_danger_spec.rb b/spec/lib/gitlab_danger_spec.rb index 49c7a46f321..b534823a888 100644 --- a/spec/lib/gitlab_danger_spec.rb +++ b/spec/lib/gitlab_danger_spec.rb @@ -9,7 +9,7 @@ RSpec.describe GitlabDanger do describe '.local_warning_message' do it 'returns an informational message with rules that can run' do - expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, karma, database, commit_messages, telemetry, utility_css') + expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, karma, database, commit_messages, telemetry, utility_css, pajamas') end end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index eb2c4a3fbd5..7c008fcd0da 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -912,7 +912,7 @@ RSpec.describe API::MergeRequests do let(:parent_group) { create(:group) } before do - group.update(parent_id: parent_group.id) + group.update!(parent_id: parent_group.id) merge_request_merged.reload end @@ -1027,7 +1027,7 @@ RSpec.describe API::MergeRequests do let(:non_member) { create(:user) } before do - merge_request.update(author: non_member) + merge_request.update!(author: non_member) end it 'exposes first_contribution as true' do @@ -1084,8 +1084,8 @@ RSpec.describe API::MergeRequests do let(:merge_request) { create(:merge_request, :simple, author: user, source_project: project, source_branch: 'markdown', title: "Test") } before do - merge_request.update(head_pipeline: create(:ci_pipeline)) - merge_request.project.project_feature.update(builds_access_level: 10) + merge_request.update!(head_pipeline: create(:ci_pipeline)) + merge_request.project.project_feature.update!(builds_access_level: 10) end context 'when user can read the pipeline' do @@ -1691,7 +1691,7 @@ RSpec.describe API::MergeRequests do end it 'returns 403 when target project has disabled merge requests' do - project.project_feature.update(merge_requests_access_level: 0) + project.project_feature.update!(merge_requests_access_level: 0) post api("/projects/#{forked_project.id}/merge_requests", user2), params: { @@ -2146,7 +2146,7 @@ RSpec.describe API::MergeRequests do let(:source_branch) { merge_request.source_branch } before do - merge_request.update(merge_params: { 'force_remove_source_branch' => true }) + merge_request.update!(merge_params: { 'force_remove_source_branch' => true }) end it 'removes the source branch' do @@ -2173,7 +2173,7 @@ RSpec.describe API::MergeRequests do let(:merge_request) { create(:merge_request, :rebased, source_project: project, squash: true) } before do - project.update(merge_requests_ff_only_enabled: true) + project.update!(merge_requests_ff_only_enabled: true) end it "records the squash commit SHA and returns it in the response" do @@ -2263,7 +2263,7 @@ RSpec.describe API::MergeRequests do describe "PUT /projects/:id/merge_requests/:merge_request_iid" do context 'updates force_remove_source_branch properly' do it 'sets to false' do - merge_request.update(merge_params: { 'force_remove_source_branch' => true } ) + merge_request.update!(merge_params: { 'force_remove_source_branch' => true } ) expect(merge_request.force_remove_source_branch?).to be_truthy @@ -2275,7 +2275,7 @@ RSpec.describe API::MergeRequests do end it 'sets to true' do - merge_request.update(merge_params: { 'force_remove_source_branch' => false } ) + merge_request.update!(merge_params: { 'force_remove_source_branch' => false } ) expect(merge_request.force_remove_source_branch?).to be_falsey @@ -2760,7 +2760,7 @@ RSpec.describe API::MergeRequests do merge_request merge_request.created_at += 1.hour merge_request.updated_at += 30.minutes - merge_request.save + merge_request.save! merge_request end @@ -2768,7 +2768,7 @@ RSpec.describe API::MergeRequests do merge_request_closed merge_request_closed.created_at -= 1.hour merge_request_closed.updated_at -= 30.minutes - merge_request_closed.save + merge_request_closed.save! merge_request_closed end end diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index ca4ebd3689f..baab72d106f 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -81,7 +81,7 @@ RSpec.describe API::Notes do context "issue is confidential" do before do - ext_issue.update(confidential: true) + ext_issue.update!(confidential: true) end it "returns 404" do @@ -183,7 +183,7 @@ RSpec.describe API::Notes do context "when issue is confidential" do before do - issue.update(confidential: true) + issue.update!(confidential: true) end it "returns 404" do diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index 5b6ffabb7ac..dbba2b35d74 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -763,7 +763,7 @@ RSpec.describe 'Git HTTP requests' do context 'and build created by' do before do - build.update(user: user) + build.update!(user: user) project.add_reporter(user) end diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index fd4261fb50d..31bb0586e9f 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -786,7 +786,7 @@ RSpec.describe 'Git LFS API and storage' do let(:authorization) { authorize_deploy_key } let(:update_user_permissions) do - project.deploy_keys_projects.create(deploy_key: key, can_push: true) + project.deploy_keys_projects.create!(deploy_key: key, can_push: true) end it_behaves_like 'pushes new LFS objects', renew_authorization: false @@ -991,7 +991,7 @@ RSpec.describe 'Git LFS API and storage' do context 'and workhorse requests upload finalize for a new LFS object' do before do - lfs_object.destroy + lfs_object.destroy! end context 'with object storage disabled' do @@ -1009,7 +1009,7 @@ RSpec.describe 'Git LFS API and storage' do end let(:tmp_object) do - fog_connection.directories.new(key: 'lfs-objects').files.create( + fog_connection.directories.new(key: 'lfs-objects').files.create( # rubocop: disable Rails/SaveBang key: 'tmp/uploads/12312300', body: 'content' ) @@ -1080,7 +1080,7 @@ RSpec.describe 'Git LFS API and storage' do context 'without the lfs object' do before do - lfs_object.destroy + lfs_object.destroy! end it 'rejects slashes in the tempfile name (path traversal)' do diff --git a/spec/requests/profiles/notifications_controller_spec.rb b/spec/requests/profiles/notifications_controller_spec.rb index d162f5b220d..87669b3594c 100644 --- a/spec/requests/profiles/notifications_controller_spec.rb +++ b/spec/requests/profiles/notifications_controller_spec.rb @@ -5,8 +5,8 @@ require 'spec_helper' RSpec.describe 'view user notifications' do let(:user) do create(:user) do |user| - user.emails.create(email: 'original@example.com', confirmed_at: Time.current) - user.emails.create(email: 'new@example.com', confirmed_at: Time.current) + user.emails.create!(email: 'original@example.com', confirmed_at: Time.current) + user.emails.create!(email: 'new@example.com', confirmed_at: Time.current) user.notification_email = 'original@example.com' user.save! end diff --git a/spec/support/shared_examples/controllers/issuables_list_metadata_shared_examples.rb b/spec/support/shared_examples/controllers/issuables_list_metadata_shared_examples.rb index 62a1a07b6c1..02915206cc5 100644 --- a/spec/support/shared_examples/controllers/issuables_list_metadata_shared_examples.rb +++ b/spec/support/shared_examples/controllers/issuables_list_metadata_shared_examples.rb @@ -42,10 +42,6 @@ RSpec.shared_examples 'issuables list meta-data' do |issuable_type, action = nil let(:result_issuable) { issuables.first } let(:search) { result_issuable.title } - before do - stub_feature_flags(attempt_project_search_optimizations: true) - end - # .simple_sorts is the same across all Sortable classes sorts = ::Issue.simple_sorts.keys + %w[popularity priority label_priority] sorts.each do |sort| diff --git a/spec/support/shared_examples/uploaders/workers/object_storage/migrate_uploads_shared_examples.rb b/spec/support/shared_examples/uploaders/workers/object_storage/migrate_uploads_shared_examples.rb index f143cbc7165..5a9a3dfc2d2 100644 --- a/spec/support/shared_examples/uploaders/workers/object_storage/migrate_uploads_shared_examples.rb +++ b/spec/support/shared_examples/uploaders/workers/object_storage/migrate_uploads_shared_examples.rb @@ -63,7 +63,7 @@ RSpec.shared_examples 'uploads migration worker' do if success > 0 it 'outputs the reports' do - expect(Rails.logger).to receive(:info).with(%r{Migrated #{success}/#{total} files}) + expect(Gitlab::AppLogger).to receive(:info).with(%r{Migrated #{success}/#{total} files}) perform(uploads) end @@ -71,7 +71,7 @@ RSpec.shared_examples 'uploads migration worker' do if failures > 0 it 'outputs upload failures' do - expect(Rails.logger).to receive(:warn).with(/Error .* I am a teapot/) + expect(Gitlab::AppLogger).to receive(:warn).with(/Error .* I am a teapot/) perform(uploads) end diff --git a/spec/workers/new_issue_worker_spec.rb b/spec/workers/new_issue_worker_spec.rb index d56732770a3..570b5d9c06e 100644 --- a/spec/workers/new_issue_worker_spec.rb +++ b/spec/workers/new_issue_worker_spec.rb @@ -15,7 +15,7 @@ RSpec.describe NewIssueWorker do end it 'logs an error' do - expect(Rails.logger).to receive(:error).with('NewIssueWorker: couldn\'t find Issue with ID=99, skipping job') + expect(Gitlab::AppLogger).to receive(:error).with('NewIssueWorker: couldn\'t find Issue with ID=99, skipping job') worker.perform(99, create(:user).id) end @@ -32,7 +32,7 @@ RSpec.describe NewIssueWorker do it 'logs an error' do issue = create(:issue) - expect(Rails.logger).to receive(:error).with('NewIssueWorker: couldn\'t find User with ID=99, skipping job') + expect(Gitlab::AppLogger).to receive(:error).with('NewIssueWorker: couldn\'t find User with ID=99, skipping job') worker.perform(issue.id, 99) end diff --git a/spec/workers/new_merge_request_worker_spec.rb b/spec/workers/new_merge_request_worker_spec.rb index 37449540db5..3d78b9703fa 100644 --- a/spec/workers/new_merge_request_worker_spec.rb +++ b/spec/workers/new_merge_request_worker_spec.rb @@ -17,7 +17,7 @@ RSpec.describe NewMergeRequestWorker do it 'logs an error' do user = create(:user) - expect(Rails.logger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find MergeRequest with ID=99, skipping job') + expect(Gitlab::AppLogger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find MergeRequest with ID=99, skipping job') worker.perform(99, user.id) end @@ -34,7 +34,7 @@ RSpec.describe NewMergeRequestWorker do it 'logs an error' do merge_request = create(:merge_request) - expect(Rails.logger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find User with ID=99, skipping job') + expect(Gitlab::AppLogger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find User with ID=99, skipping job') worker.perform(merge_request.id, 99) end diff --git a/spec/workers/run_pipeline_schedule_worker_spec.rb b/spec/workers/run_pipeline_schedule_worker_spec.rb index 4999909934b..0b9f95e09fe 100644 --- a/spec/workers/run_pipeline_schedule_worker_spec.rb +++ b/spec/workers/run_pipeline_schedule_worker_spec.rb @@ -59,7 +59,7 @@ RSpec.describe RunPipelineScheduleWorker do end it 'logging a pipeline error' do - expect(Rails.logger) + expect(Gitlab::AppLogger) .to receive(:error) .with(a_string_matching('ActiveRecord::StatementInvalid')) .and_call_original |