diff options
| author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-21 06:10:27 +0000 |
|---|---|---|
| committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-21 06:10:27 +0000 |
| commit | 3c63ea4631f629f83c7d35e65963ffc1acf83161 (patch) | |
| tree | 8c907616211b88594dd828257ca2c8131a429225 | |
| parent | f2eb66fef8aa8cebea25bc9e671a1f146514682f (diff) | |
| download | gitlab-ce-3c63ea4631f629f83c7d35e65963ffc1acf83161.tar.gz | |
Add latest changes from gitlab-org/gitlab@master
23 files changed, 231 insertions, 51 deletions
diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 3bbc2d05a10..2df7975119c 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -a7f84c7c8ea135881fd2cc6c7f48fdc487b125fb +0fe0cfaccc979592610cbf65807f19b307957750 diff --git a/app/assets/javascripts/pages/projects/commit/show/index.js b/app/assets/javascripts/pages/projects/commit/show/index.js index a245af72d93..e96cfa5c9b2 100644 --- a/app/assets/javascripts/pages/projects/commit/show/index.js +++ b/app/assets/javascripts/pages/projects/commit/show/index.js @@ -18,20 +18,18 @@ import { __ } from '~/locale'; document.addEventListener('DOMContentLoaded', () => { const hasPerfBar = document.querySelector('.with-performance-bar'); const performanceHeight = hasPerfBar ? 35 : 0; + initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight + performanceHeight); + new ZenMode(); + new ShortcutsNavigation(); + new MiniPipelineGraph({ + container: '.js-commit-pipeline-graph', + }).bindEvents(); + initNotes(); + // eslint-disable-next-line no-jquery/no-load + $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); + fetchCommitMergeRequests(); + const filesContainer = $('.js-diffs-batch'); - const initAfterPageLoad = () => { - new Diff(); - new ZenMode(); - new ShortcutsNavigation(); - new MiniPipelineGraph({ - container: '.js-commit-pipeline-graph', - }).bindEvents(); - initNotes(); - initChangesDropdown(document.querySelector('.navbar-gitlab').offsetHeight + performanceHeight); - // eslint-disable-next-line no-jquery/no-load - $('.commit-info.branches').load(document.querySelector('.js-commit-box').dataset.commitPath); - fetchCommitMergeRequests(); - }; if (filesContainer.length) { const batchPath = filesContainer.data('diffFilesPath'); @@ -42,12 +40,12 @@ document.addEventListener('DOMContentLoaded', () => { filesContainer.html($(data.html)); syntaxHighlight(filesContainer); handleLocationHash(); - initAfterPageLoad(); + new Diff(); }) .catch(() => { flash(__('An error occurred while retrieving diff files')); }); } else { - initAfterPageLoad(); + new Diff(); } }); diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index f4c2d568b4d..36e458d9353 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -333,7 +333,11 @@ class MergeRequest < ApplicationRecord def merge_pipeline return unless merged? - target_project.pipeline_for(target_branch, merge_commit_sha) + # When the merge_method is :merge there will be a merge_commit_sha, however + # when it is fast-forward there is no merge commit, so we must fall back to + # either the squash commit (if the MR was squashed) or the diff head commit. + sha = merge_commit_sha || squash_commit_sha || diff_head_sha + target_project.pipeline_for(target_branch, sha) end # Pattern used to extract `!123` merge request references from text diff --git a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml index 3fc6a3b545b..abf5f58699f 100644 --- a/app/views/shared/issuable/_close_reopen_report_toggle.html.haml +++ b/app/views/shared/issuable/_close_reopen_report_toggle.html.haml @@ -9,7 +9,7 @@ - add_blocked_class = !issuable.closed? && warn_before_close .float-left.btn-group.gl-ml-3.issuable-close-dropdown.droplab-dropdown.js-issuable-close-dropdown - %button{ class: "#{button_class} btn-#{button_action} #{(add_blocked_class ? 'btn-issue-blocked' : '')}", data: { qa_selector: 'close_issue_button', endpoint: close_reopen_issuable_path(issuable) } } + %button{ class: "#{button_class} btn-#{button_action} #{(add_blocked_class ? 'btn-issue-blocked' : '')}", data: { testid: 'close-issue-button', qa_selector: 'close_issue_button', endpoint: close_reopen_issuable_path(issuable) } } #{display_button_action} #{display_issuable_type} = button_tag type: 'button', class: "#{toggle_class} btn-#{button_action}-color", diff --git a/changelogs/unreleased/230437-usage-data-optimize-counts-terraform_reports.yml b/changelogs/unreleased/230437-usage-data-optimize-counts-terraform_reports.yml new file mode 100644 index 00000000000..a8b7c06937f --- /dev/null +++ b/changelogs/unreleased/230437-usage-data-optimize-counts-terraform_reports.yml @@ -0,0 +1,5 @@ +--- +title: Optimize counts.terraform_reports usage ping counter +merge_request: 39499 +author: +type: performance diff --git a/changelogs/unreleased/237876-update-prismjs-to-1-21-0.yml b/changelogs/unreleased/237876-update-prismjs-to-1-21-0.yml new file mode 100644 index 00000000000..98727e87086 --- /dev/null +++ b/changelogs/unreleased/237876-update-prismjs-to-1-21-0.yml @@ -0,0 +1,5 @@ +--- +title: Update prismjs from 1.6.0 to 1.21.0 +merge_request: 39593 +author: Takuya Noguchi +type: other diff --git a/changelogs/unreleased/fix-pipeline-link.yml b/changelogs/unreleased/fix-pipeline-link.yml new file mode 100644 index 00000000000..b1523a400ef --- /dev/null +++ b/changelogs/unreleased/fix-pipeline-link.yml @@ -0,0 +1,5 @@ +--- +title: Fixes wrong MR pipeline link when FF-merge strategy is used +merge_request: 39396 +author: +type: fixed diff --git a/db/post_migrate/20200811211536_add_index_to_ci_job_artifacts_for_terraform_reports_id.rb b/db/post_migrate/20200811211536_add_index_to_ci_job_artifacts_for_terraform_reports_id.rb new file mode 100644 index 00000000000..6042f90cf85 --- /dev/null +++ b/db/post_migrate/20200811211536_add_index_to_ci_job_artifacts_for_terraform_reports_id.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class AddIndexToCiJobArtifactsForTerraformReportsId < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INDEX_NAME = 'index_ci_job_artifacts_id_for_terraform_reports' + + disable_ddl_transaction! + + def up + add_concurrent_index :ci_job_artifacts, :id, where: 'file_type = 18', name: INDEX_NAME + end + + def down + remove_concurrent_index_by_name :ci_job_artifacts, INDEX_NAME + end +end diff --git a/db/post_migrate/20200817100710_add_section_and_created_at_codeowner_approval_merge_request_index.rb b/db/post_migrate/20200817100710_add_section_and_created_at_codeowner_approval_merge_request_index.rb new file mode 100644 index 00000000000..33de4f1f790 --- /dev/null +++ b/db/post_migrate/20200817100710_add_section_and_created_at_codeowner_approval_merge_request_index.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +class AddSectionAndCreatedAtCodeownerApprovalMergeRequestIndex < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + SECTION_CREATED_AT_ON_CODEOWNER_APPROVAL_MERGE_REQUEST_RULES = "index_created_at_on_codeowner_approval_merge_request_rules" + RULE_TYPE_CODEOWNERS = 2 + CODEOWNER_SECTION_DEFAULT = 'codeowners' + + disable_ddl_transaction! + + def up + add_concurrent_index :approval_merge_request_rules, :created_at, + where: "rule_type = #{RULE_TYPE_CODEOWNERS} AND section != '#{CODEOWNER_SECTION_DEFAULT}'::text", + name: SECTION_CREATED_AT_ON_CODEOWNER_APPROVAL_MERGE_REQUEST_RULES + end + + def down + remove_concurrent_index_by_name :approval_merge_request_rules, SECTION_CREATED_AT_ON_CODEOWNER_APPROVAL_MERGE_REQUEST_RULES + end +end diff --git a/db/schema_migrations/20200811211536 b/db/schema_migrations/20200811211536 new file mode 100644 index 00000000000..1bd013900a3 --- /dev/null +++ b/db/schema_migrations/20200811211536 @@ -0,0 +1 @@ +d4ea24092289f6dba294c502b8ce89748165973fb2d7989fa7615433599a0c0c
\ No newline at end of file diff --git a/db/schema_migrations/20200817100710 b/db/schema_migrations/20200817100710 new file mode 100644 index 00000000000..8062c3d46e4 --- /dev/null +++ b/db/schema_migrations/20200817100710 @@ -0,0 +1 @@ +87d3529596f5b5adff7280be7c60e4ff290dd05c500bbeb00cda0ac5da6239e0
\ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 033fc85305c..7fdde701fbf 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -19234,6 +19234,8 @@ CREATE UNIQUE INDEX index_ci_instance_variables_on_key ON public.ci_instance_var CREATE INDEX index_ci_job_artifacts_for_terraform_reports ON public.ci_job_artifacts USING btree (project_id, id) WHERE (file_type = 18); +CREATE INDEX index_ci_job_artifacts_id_for_terraform_reports ON public.ci_job_artifacts USING btree (id) WHERE (file_type = 18); + CREATE INDEX index_ci_job_artifacts_on_expire_at_and_job_id ON public.ci_job_artifacts USING btree (expire_at, job_id); CREATE INDEX index_ci_job_artifacts_on_file_store ON public.ci_job_artifacts USING btree (file_store); @@ -19456,6 +19458,8 @@ CREATE UNIQUE INDEX index_container_repositories_on_project_id_and_name ON publi CREATE INDEX index_container_repository_on_name_trigram ON public.container_repositories USING gin (name public.gin_trgm_ops); +CREATE INDEX index_created_at_on_codeowner_approval_merge_request_rules ON public.approval_merge_request_rules USING btree (created_at) WHERE ((rule_type = 2) AND (section <> 'codeowners'::text)); + CREATE UNIQUE INDEX index_custom_emoji_on_namespace_id_and_name ON public.custom_emoji USING btree (namespace_id, name); CREATE UNIQUE INDEX index_daily_build_group_report_results_unique_columns ON public.ci_daily_build_group_report_results USING btree (project_id, ref_path, date, group_name); diff --git a/doc/user/project/issues/index.md b/doc/user/project/issues/index.md index a6911d183c1..87b705bca94 100644 --- a/doc/user/project/issues/index.md +++ b/doc/user/project/issues/index.md @@ -186,8 +186,8 @@ requires [GraphQL](../../../api/graphql/index.md) to be enabled. ### Health status **(ULTIMATE)** -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/36427) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.10. - +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/36427) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 12.10. +> - Health status of closed issues [can't be edited](https://gitlab.com/gitlab-org/gitlab/-/issues/220867) in [GitLab Ultimate](https://about.gitlab.com/pricing/) 13.4 and later. To help you track the status of your issues, you can assign a status to each issue to flag work that's progressing as planned or needs attention to keep on schedule: @@ -197,6 +197,9 @@ that's progressing as planned or needs attention to keep on schedule:  +After an issue is closed, its health status can't be edited and the "Edit" button becomes disabled +until the issue is reopened. + You can then see issue statuses on the [Epic tree](../../group/epics/index.md#issue-health-status-in-epic-tree-ultimate). diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index f4d3186657f..19faaaacf9a 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -716,6 +716,18 @@ module Gitlab end end + def project_minimum_id + strong_memoize(:project_minimum_id) do + ::Project.minimum(:id) + end + end + + def project_maximum_id + strong_memoize(:project_maximum_id) do + ::Project.maximum(:id) + end + end + def clear_memoized clear_memoization(:issue_minimum_id) clear_memoization(:issue_maximum_id) @@ -726,6 +738,8 @@ module Gitlab clear_memoization(:deployment_maximum_id) clear_memoization(:approval_merge_request_rule_minimum_id) clear_memoization(:approval_merge_request_rule_maximum_id) + clear_memoization(:project_minimum_id) + clear_memoization(:project_maximum_id) end # rubocop: disable CodeReuse/ActiveRecord diff --git a/lib/product_analytics/tracker.rb b/lib/product_analytics/tracker.rb index d4a88b879f0..2dc5e1f53ce 100644 --- a/lib/product_analytics/tracker.rb +++ b/lib/product_analytics/tracker.rb @@ -7,5 +7,36 @@ module ProductAnalytics # The collector URL minus protocol and /i COLLECTOR_URL = Gitlab.config.gitlab.url.sub(/\Ahttps?\:\/\//, '') + '/-/collector' + + class << self + include Gitlab::Utils::StrongMemoize + + def event(category, action, label: nil, property: nil, value: nil, context: nil) + return unless enabled? + + snowplow.track_struct_event(category, action, label, property, value, context, (Time.now.to_f * 1000).to_i) + end + + private + + def enabled? + Gitlab::CurrentSettings.usage_ping_enabled? + end + + def project_id + Gitlab::CurrentSettings.self_monitoring_project_id + end + + def snowplow + strong_memoize(:snowplow) do + SnowplowTracker::Tracker.new( + SnowplowTracker::AsyncEmitter.new(COLLECTOR_URL, protocol: Gitlab.config.gitlab.protocol), + SnowplowTracker::Subject.new, + Gitlab::Tracking::SNOWPLOW_NAMESPACE, + project_id.to_s + ) + end + end + end end end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 04032cc4abb..6e7c11c29d3 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -12451,6 +12451,9 @@ msgstr "" msgid "Health status" msgstr "" +msgid "Health status cannot be edited because this issue is closed" +msgstr "" + msgid "HealthCheck|Access token is" msgstr "" diff --git a/package.json b/package.json index 97055523636..0aa69e4f790 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "pdfjs-dist": "^2.0.943", "pikaday": "^1.8.0", "popper.js": "^1.16.1", - "prismjs": "^1.6.0", + "prismjs": "^1.21.0", "prosemirror-markdown": "^1.3.0", "prosemirror-model": "^1.6.4", "raphael": "^2.2.7", diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 7bd3bce85d5..cf9b86f16bb 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -26,8 +26,6 @@ RSpec.describe 'Mini Pipeline Graph in Commit View', :js do build.run visit project_commit_path(project, project.commit.id) - wait_for_all_requests - expect(page).to have_selector('.mr-widget-pipeline-graph') first('.mini-pipeline-graph-dropdown-toggle').click diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 589c11f79a7..d38635292a5 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -25,6 +25,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do it 'clears memoized values' do values = %i(issue_minimum_id issue_maximum_id + project_minimum_id project_maximum_id user_minimum_id user_maximum_id unique_visit_service deployment_minimum_id deployment_maximum_id approval_merge_request_rule_minimum_id diff --git a/spec/lib/product_analytics/tracker_spec.rb b/spec/lib/product_analytics/tracker_spec.rb index d5e85e6e1cd..0d0660235f1 100644 --- a/spec/lib/product_analytics/tracker_spec.rb +++ b/spec/lib/product_analytics/tracker_spec.rb @@ -1,8 +1,57 @@ # frozen_string_literal: true -require "spec_helper" +require 'spec_helper' RSpec.describe ProductAnalytics::Tracker do it { expect(described_class::URL).to eq('http://localhost/-/sp.js') } it { expect(described_class::COLLECTOR_URL).to eq('localhost/-/collector') } + + describe '.event' do + after do + described_class.clear_memoization(:snowplow) + end + + context 'when usage ping is enabled' do + let(:tracker) { double } + let(:project_id) { 1 } + + before do + stub_application_setting(usage_ping_enabled: true, self_monitoring_project_id: project_id) + end + + it 'sends an event to Product Analytics snowplow collector' do + expect(SnowplowTracker::AsyncEmitter) + .to receive(:new) + .with(described_class::COLLECTOR_URL, { protocol: 'http' }) + .and_return('_emitter_') + + expect(SnowplowTracker::Tracker) + .to receive(:new) + .with('_emitter_', an_instance_of(SnowplowTracker::Subject), 'gl', project_id.to_s) + .and_return(tracker) + + freeze_time do + expect(tracker) + .to receive(:track_struct_event) + .with('category', 'action', '_label_', '_property_', '_value_', nil, (Time.current.to_f * 1000).to_i) + + described_class.event('category', 'action', label: '_label_', property: '_property_', + value: '_value_', context: nil) + end + end + end + + context 'when usage ping is disabled' do + before do + stub_application_setting(usage_ping_enabled: false) + end + + it 'does not send an event' do + expect(SnowplowTracker::Tracker).not_to receive(:new) + + described_class.event('category', 'action', label: '_label_', property: '_property_', + value: '_value_', context: nil) + end + end + end end diff --git a/spec/models/environment_status_spec.rb b/spec/models/environment_status_spec.rb index 7eefb8f714a..a6954fb5d56 100644 --- a/spec/models/environment_status_spec.rb +++ b/spec/models/environment_status_spec.rb @@ -90,22 +90,6 @@ RSpec.describe EnvironmentStatus do end end - describe '.after_merge_request' do - let(:admin) { create(:admin) } - let(:pipeline) { create(:ci_pipeline, sha: sha) } - - before do - merge_request.mark_as_merged! - end - - it 'is based on merge_request.merge_commit_sha' do - expect(merge_request).to receive(:merge_commit_sha) - expect(merge_request).not_to receive(:diff_head_sha) - - described_class.after_merge_request(merge_request, admin) - end - end - describe '.for_deployed_merge_request' do context 'when a merge request has no explicitly linked deployments' do it 'returns the statuses based on the CI pipelines' do @@ -191,7 +175,7 @@ RSpec.describe EnvironmentStatus do let(:environment) { build.deployment.environment } let(:user) { project.owner } - context 'when environment is created on a forked project' do + context 'when environment is created on a forked project', :sidekiq_inline do let(:project) { create(:project, :repository) } let(:forked) { fork_project(project, user, repository: true) } let(:sha) { forked.commit.sha } @@ -205,7 +189,7 @@ RSpec.describe EnvironmentStatus do head_pipeline: pipeline) end - it 'returns environment status', :sidekiq_might_not_need_inline do + it 'returns environment status' do expect(subject.count).to eq(1) expect(subject[0].environment).to eq(environment) expect(subject[0].merge_request).to eq(merge_request) diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 6edef54b153..656a93cee62 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1575,11 +1575,36 @@ RSpec.describe MergeRequest do before do subject.mark_as_merged! - subject.update_attribute(:merge_commit_sha, pipeline.sha) end - it 'returns the post-merge pipeline' do - expect(subject.merge_pipeline).to eq(pipeline) + context 'and there is a merge commit' do + before do + subject.update_attribute(:merge_commit_sha, pipeline.sha) + end + + it 'returns the pipeline associated with that merge request' do + expect(subject.merge_pipeline).to eq(pipeline) + end + end + + context 'and there is no merge commit, but there is a diff head' do + before do + allow(subject).to receive(:diff_head_sha).and_return(pipeline.sha) + end + + it 'returns the pipeline associated with that merge request' do + expect(subject.merge_pipeline).to eq(pipeline) + end + end + + context 'and there is no merge commit, but there is a squash commit' do + before do + subject.update_attribute(:squash_commit_sha, pipeline.sha) + end + + it 'returns the pipeline associated with that merge request' do + expect(subject.merge_pipeline).to eq(pipeline) + end end end end diff --git a/yarn.lock b/yarn.lock index 4686d870740..7a4fc6c234e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2858,7 +2858,7 @@ cli-width@^2.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639" integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk= -clipboard@^1.5.5, clipboard@^1.7.1: +clipboard@^1.7.1: version "1.7.1" resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-1.7.1.tgz#360d6d6946e99a7a1fef395e42ba92b5e9b5a16b" integrity sha1-Ng1taUbpmnof7zleQrqStem1oWs= @@ -2867,6 +2867,15 @@ clipboard@^1.5.5, clipboard@^1.7.1: select "^1.1.2" tiny-emitter "^2.0.0" +clipboard@^2.0.0: + version "2.0.6" + resolved "https://registry.yarnpkg.com/clipboard/-/clipboard-2.0.6.tgz#52921296eec0fdf77ead1749421b21c968647376" + integrity sha512-g5zbiixBRk/wyKakSwCKd7vQXDjFnAMGHoEyBogG/bw9kTD9GvdAvaoRR1ALcEzt3pVKxZR0pViekPMIS0QyGg== + dependencies: + good-listener "^1.2.2" + select "^1.1.2" + tiny-emitter "^2.0.0" + cliui@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" @@ -9530,12 +9539,12 @@ pretty@^2.0.0: extend-shallow "^2.0.1" js-beautify "^1.6.12" -prismjs@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.6.0.tgz#118d95fb7a66dba2272e343b345f5236659db365" - integrity sha1-EY2V+3pm26InLjQ7NF9SNmWds2U= +prismjs@^1.21.0: + version "1.21.0" + resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.21.0.tgz#36c086ec36b45319ec4218ee164c110f9fc015a3" + integrity sha512-uGdSIu1nk3kej2iZsLyDoJ7e9bnPzIgY0naW/HdknGj61zScaprVEVGHrPoXqI+M9sP0NDnTK2jpkvmldpuqDw== optionalDependencies: - clipboard "^1.5.5" + clipboard "^2.0.0" private@^0.1.8: version "0.1.8" |
