From 5e13b3a9e58a7b78e93b4aa5a12cc19bd6bca674 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 12 Nov 2021 00:10:48 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- app/controllers/concerns/issuable_actions.rb | 2 +- ...l => between_commits_via_list_commits.yml} | 8 +-- ...geCommitMessageWithDescription-graphql.yml | 14 ++++++ ...date_vulnerability_occurrences_location.rb | 2 + doc/update/deprecations.md | 6 +++ lib/gitlab/gitaly_client/commit_service.rb | 2 + .../gitaly_client/commit_service_spec.rb | 37 +++++++++++--- .../projects/issues/discussions_spec.rb | 50 +++++++------------ 8 files changed, 76 insertions(+), 45 deletions(-) rename config/feature_flags/development/{issue_discussions_http_cache.yml => between_commits_via_list_commits.yml} (67%) create mode 100644 data/deprecations/deprecate-defaultMergeCommitMessageWithDescription-graphql.yml diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index 414210ee16a..8a9b66045b8 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -160,7 +160,7 @@ module IssuableActions if issuable.is_a?(MergeRequest) render_cached(discussions, with: discussion_serializer, cache_context: -> (_) { discussion_cache_context }, context: self) - elsif issuable.is_a?(Issue) && Feature.enabled?(:issue_discussions_http_cache, default_enabled: :yaml) + elsif issuable.is_a?(Issue) render json: discussion_serializer.represent(discussions, context: self) if stale?(etag: [discussion_cache_context, discussions]) else render json: discussion_serializer.represent(discussions, context: self) diff --git a/config/feature_flags/development/issue_discussions_http_cache.yml b/config/feature_flags/development/between_commits_via_list_commits.yml similarity index 67% rename from config/feature_flags/development/issue_discussions_http_cache.yml rename to config/feature_flags/development/between_commits_via_list_commits.yml index 93519421949..f048fd4e1b6 100644 --- a/config/feature_flags/development/issue_discussions_http_cache.yml +++ b/config/feature_flags/development/between_commits_via_list_commits.yml @@ -1,8 +1,8 @@ --- -name: issue_discussions_http_cache -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/72589 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/343309 +name: between_commits_via_list_commits +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74273 +rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/345458 milestone: '14.5' type: development -group: group::project management +group: group::gitaly default_enabled: false diff --git a/data/deprecations/deprecate-defaultMergeCommitMessageWithDescription-graphql.yml b/data/deprecations/deprecate-defaultMergeCommitMessageWithDescription-graphql.yml new file mode 100644 index 00000000000..eba37d1eb8f --- /dev/null +++ b/data/deprecations/deprecate-defaultMergeCommitMessageWithDescription-graphql.yml @@ -0,0 +1,14 @@ +- name: "defaultMergeCommitMessageWithDescription GraphQL API field will be removed in GitLab 15.0" # The name of the feature to be deprecated + announcement_milestone: "14.5" # The milestone when this feature was first announced as deprecated. + announcement_date: "2021-11-22" # The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post. + removal_milestone: "15.0" # The milestone when this feature is planned to be removed + body: | # Do not modify this line, instead modify the lines below. + The GraphQL API field `defaultMergeCommitMessageWithDescription` has been deprecated and will be removed in GitLab 15.0. For projects with a commit message template set, it will ignore the template. +# The following items are not published on the docs page, but may be used in the future. + stage: # (optional - may be required in the future) String value of the stage that the feature was created in. e.g., Growth + tiers: # (optional - may be required in the future) An array of tiers that the feature is available in currently. e.g., [Free, Silver, Gold, Core, Premium, Ultimate] + issue_url: # (optional) This is a link to the deprecation issue in GitLab + documentation_url: # (optional) This is a link to the current documentation page + image_url: # (optional) This is a link to a thumbnail image depicting the feature + video_url: # (optional) Use the youtube thumbnail URL with the structure of https://img.youtube.com/vi/UNIQUEID/hqdefault.jpg + removal_date: # (optional - may be required in the future) YYYY-MM-DD format. This should almost always be the 22nd of a month (YYYY-MM-22), the date of the milestone release when this feature is planned to be removed diff --git a/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb b/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb index 20618b78391..44e2630af06 100644 --- a/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb +++ b/db/post_migrate/20211102114802_update_vulnerability_occurrences_location.rb @@ -8,6 +8,8 @@ class UpdateVulnerabilityOccurrencesLocation < Gitlab::Database::Migration[1.0] disable_ddl_transaction! def up + return unless Gitlab.ee? + relation = Gitlab::BackgroundMigration::UpdateVulnerabilityOccurrencesLocation::Occurrence.where(location: nil) queue_background_migration_jobs_by_range_at_intervals(relation, MIGRATION_NAME, diff --git a/doc/update/deprecations.md b/doc/update/deprecations.md index a39ed62a2f2..37de62be387 100644 --- a/doc/update/deprecations.md +++ b/doc/update/deprecations.md @@ -157,6 +157,12 @@ Prior to 14.5, if you did not define the `AuthenticationType`, GitLab Runner cho Announced: 2021-11-22 +### defaultMergeCommitMessageWithDescription GraphQL API field will be removed in GitLab 15.0 + +The GraphQL API field `defaultMergeCommitMessageWithDescription` has been deprecated and will be removed in GitLab 15.0. For projects with a commit message template set, it will ignore the template. + +Announced: 2021-11-22 + ## 15.2 ### NFS for Git repository storage deprecated diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb index 75588ad980c..7c688044e9c 100644 --- a/lib/gitlab/gitaly_client/commit_service.rb +++ b/lib/gitlab/gitaly_client/commit_service.rb @@ -205,6 +205,8 @@ module Gitlab end def between(from, to) + return list_commits(["^" + from, to], reverse: true) if Feature.enabled?(:between_commits_via_list_commits) + request = Gitaly::CommitsBetweenRequest.new( repository: @gitaly_repo, from: from, diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb index 554a91f2bc5..d8e397dd6f3 100644 --- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb @@ -112,15 +112,38 @@ RSpec.describe Gitlab::GitalyClient::CommitService do let(:from) { 'master' } let(:to) { Gitlab::Git::EMPTY_TREE_ID } - it 'sends an RPC request' do - request = Gitaly::CommitsBetweenRequest.new( - repository: repository_message, from: from, to: to - ) + context 'with between_commits_via_list_commits enabled' do + before do + stub_feature_flags(between_commits_via_list_commits: true) + end - expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:commits_between) - .with(request, kind_of(Hash)).and_return([]) + it 'sends an RPC request' do + request = Gitaly::ListCommitsRequest.new( + repository: repository_message, revisions: ["^" + from, to], reverse: true + ) - described_class.new(repository).between(from, to) + expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:list_commits) + .with(request, kind_of(Hash)).and_return([]) + + described_class.new(repository).between(from, to) + end + end + + context 'with between_commits_via_list_commits disabled' do + before do + stub_feature_flags(between_commits_via_list_commits: false) + end + + it 'sends an RPC request' do + request = Gitaly::CommitsBetweenRequest.new( + repository: repository_message, from: from, to: to + ) + + expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:commits_between) + .with(request, kind_of(Hash)).and_return([]) + + described_class.new(repository).between(from, to) + end end end diff --git a/spec/requests/projects/issues/discussions_spec.rb b/spec/requests/projects/issues/discussions_spec.rb index 747cc0e6c6c..dcdca2d9c27 100644 --- a/spec/requests/projects/issues/discussions_spec.rb +++ b/spec/requests/projects/issues/discussions_spec.rb @@ -14,31 +14,21 @@ RSpec.describe 'issue discussions' do project.add_maintainer(user) end - def get_discussions - get discussions_namespace_project_issue_path(namespace_id: project.namespace, project_id: project, id: issue.iid), headers: { - 'If-None-Match' => @etag - } + context 'HTTP caching' do + def get_discussions + get discussions_namespace_project_issue_path(namespace_id: project.namespace, project_id: project, id: issue.iid), headers: { + 'If-None-Match' => @etag + } - @etag = response.etag - end + @etag = response.etag + end - before do - sign_in(user) - - get_discussions - end - - shared_examples 'cache miss' do - it 'returns 200 and serializes JSON' do - expect(DiscussionSerializer).to receive(:new).and_call_original + before do + sign_in(user) get_discussions - - expect(response).to have_gitlab_http_status(:ok) end - end - shared_examples 'cache hit' do it 'returns 304 without serializing JSON' do expect(DiscussionSerializer).not_to receive(:new) @@ -46,23 +36,17 @@ RSpec.describe 'issue discussions' do expect(response).to have_gitlab_http_status(:not_modified) end - end - context 'when issue_discussions_http_cache is disabled' do - before do - stub_feature_flags(issue_discussions_http_cache: false) + shared_examples 'cache miss' do + it 'returns 200 and serializes JSON' do + expect(DiscussionSerializer).to receive(:new).and_call_original + + get_discussions + + expect(response).to have_gitlab_http_status(:ok) + end end - it_behaves_like 'cache miss' - end - - context 'when issue_discussions_http_cache is enabled' do - before do - stub_feature_flags(issue_discussions_http_cache: true) - end - - it_behaves_like 'cache hit' - context 'when user role changes' do before do project.add_guest(user)