Commit 2608f81c authored by Patrick Bajao's avatar Patrick Bajao

Remove default_merge_ref_for_diffs feature fflag

The feature has been enabled by default for a while now and no
blocking issues were found.

Changelog: other
parent a9b04d35
...@@ -15,24 +15,19 @@ export const diffCompareDropdownTargetVersions = (state, getters) => { ...@@ -15,24 +15,19 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
// startVersion only exists if the user has selected a version other // startVersion only exists if the user has selected a version other
// than "base" so if startVersion is null then base must be selected // than "base" so if startVersion is null then base must be selected
const defaultMergeRefForDiffs = window.gon?.features?.defaultMergeRefForDiffs || false;
const diffHeadParam = getParameterByName('diff_head'); const diffHeadParam = getParameterByName('diff_head');
const diffHead = parseBoolean(diffHeadParam) || (!diffHeadParam && defaultMergeRefForDiffs); const diffHead = parseBoolean(diffHeadParam) || !diffHeadParam;
const isBaseSelected = !state.startVersion && !diffHead; const isBaseSelected = !state.startVersion;
const isHeadSelected = !state.startVersion && diffHead; const isHeadSelected = !state.startVersion && diffHead;
let baseVersion = null; let baseVersion = null;
if ( if (!state.mergeRequestDiff.head_version_path) {
!defaultMergeRefForDiffs ||
(defaultMergeRefForDiffs && !state.mergeRequestDiff.head_version_path)
) {
baseVersion = { baseVersion = {
versionName: state.targetBranchName, versionName: state.targetBranchName,
version_index: DIFF_COMPARE_BASE_VERSION_INDEX, version_index: DIFF_COMPARE_BASE_VERSION_INDEX,
href: state.mergeRequestDiff.base_version_path, href: state.mergeRequestDiff.base_version_path,
isBase: true, isBase: true,
selected: selected: isBaseSelected,
isBaseSelected || (defaultMergeRefForDiffs && !state.mergeRequestDiff.head_version_path),
}; };
} }
......
...@@ -37,7 +37,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -37,7 +37,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
before_action only: [:show] do before_action only: [:show] do
push_frontend_feature_flag(:file_identifier_hash) push_frontend_feature_flag(:file_identifier_hash)
push_frontend_feature_flag(:merge_request_widget_graphql, project, default_enabled: :yaml) push_frontend_feature_flag(:merge_request_widget_graphql, project, default_enabled: :yaml)
push_frontend_feature_flag(:default_merge_ref_for_diffs, project, default_enabled: :yaml)
push_frontend_feature_flag(:core_security_mr_widget_counts, project) push_frontend_feature_flag(:core_security_mr_widget_counts, project)
push_frontend_feature_flag(:paginated_notes, project, default_enabled: :yaml) push_frontend_feature_flag(:paginated_notes, project, default_enabled: :yaml)
push_frontend_feature_flag(:confidential_notes, project, default_enabled: :yaml) push_frontend_feature_flag(:confidential_notes, project, default_enabled: :yaml)
...@@ -553,12 +552,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo ...@@ -553,12 +552,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end end
def endpoint_metadata_url(project, merge_request) def endpoint_metadata_url(project, merge_request)
params = request.query_parameters params = request.query_parameters.merge(view: 'inline', diff_head: true)
params[:view] = "inline"
if Feature.enabled?(:default_merge_ref_for_diffs, project, default_enabled: :yaml)
params = params.merge(diff_head: true)
end
diffs_metadata_project_json_merge_request_path(project, merge_request, 'json', params) diffs_metadata_project_json_merge_request_path(project, merge_request, 'json', params)
end end
......
...@@ -9,7 +9,6 @@ module MergeRequests ...@@ -9,7 +9,6 @@ module MergeRequests
end end
def execute def execute
return error("default_merge_ref_for_diffs feature flag is disabled") unless enabled?
return error("Merge request has no merge ref head.") unless merge_request.merge_ref_head.present? return error("Merge request has no merge ref head.") unless merge_request.merge_ref_head.present?
error_msg = recreate_merge_head_diff error_msg = recreate_merge_head_diff
...@@ -23,10 +22,6 @@ module MergeRequests ...@@ -23,10 +22,6 @@ module MergeRequests
attr_reader :merge_request attr_reader :merge_request
def enabled?
Feature.enabled?(:default_merge_ref_for_diffs, merge_request.project, default_enabled: :yaml)
end
def recreate_merge_head_diff def recreate_merge_head_diff
merge_request.merge_head_diff&.destroy! merge_request.merge_head_diff&.destroy!
......
...@@ -76,9 +76,7 @@ ...@@ -76,9 +76,7 @@
= render "projects/merge_requests/tabs/pane", name: "pipelines", id: "pipelines", class: "pipelines" do = render "projects/merge_requests/tabs/pane", name: "pipelines", id: "pipelines", class: "pipelines" do
- if @number_of_pipelines.nonzero? - if @number_of_pipelines.nonzero?
= render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request) = render 'projects/commit/pipelines_list', disable_initialization: true, endpoint: pipelines_project_merge_request_path(@project, @merge_request)
- params = request.query_parameters - params = request.query_parameters.merge(diff_head: true)
- if Feature.enabled?(:default_merge_ref_for_diffs, @project, default_enabled: :yaml)
- params = params.merge(diff_head: true)
= render "projects/merge_requests/tabs/pane", name: "diffs", id: "js-diffs-app", class: "diffs", data: diffs_tab_pane_data(@project, @merge_request, params) = render "projects/merge_requests/tabs/pane", name: "diffs", id: "js-diffs-app", class: "diffs", data: diffs_tab_pane_data(@project, @merge_request, params)
.mr-loading-status .mr-loading-status
......
---
name: default_merge_ref_for_diffs
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/34472
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/276917
milestone: '13.4'
type: development
group: group::code review
default_enabled: true
...@@ -220,29 +220,6 @@ RSpec.describe Projects::MergeRequests::DiffsController do ...@@ -220,29 +220,6 @@ RSpec.describe Projects::MergeRequests::DiffsController do
end end
end end
context "with the :default_merge_ref_for_diffs flag on" do
let(:diffable_merge_ref) { true }
subject do
go(diff_head: true,
diff_id: merge_request.merge_request_diff.id,
start_sha: merge_request.merge_request_diff.start_commit_sha)
end
it "correctly generates the right diff between versions" do
MergeRequests::MergeToRefService.new(project: project, current_user: merge_request.author).execute(merge_request)
expect_next_instance_of(CompareService) do |service|
expect(service).to receive(:execute).with(
project,
merge_request.merge_request_diff.head_commit_sha,
straight: true)
end
subject
end
end
context 'with diff_head param passed' do context 'with diff_head param passed' do
before do before do
allow(merge_request).to receive(:diffable_merge_ref?) allow(merge_request).to receive(:diffable_merge_ref?)
...@@ -259,6 +236,23 @@ RSpec.describe Projects::MergeRequests::DiffsController do ...@@ -259,6 +236,23 @@ RSpec.describe Projects::MergeRequests::DiffsController do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
context 'when diff_id and start_sha are set' do
it 'correctly generates the right diff between versions' do
MergeRequests::MergeToRefService.new(project: project, current_user: merge_request.author).execute(merge_request)
expect_next_instance_of(CompareService) do |service|
expect(service).to receive(:execute).with(
project,
merge_request.merge_request_diff.head_commit_sha,
straight: true)
end
go(diff_head: true,
diff_id: merge_request.merge_request_diff.id,
start_sha: merge_request.merge_request_diff.start_commit_sha)
end
end
end end
context 'the merge request cannot be compared with head' do context 'the merge request cannot be compared with head' do
......
...@@ -68,6 +68,18 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -68,6 +68,18 @@ RSpec.describe Projects::MergeRequestsController do
end end
describe 'as html' do describe 'as html' do
it 'sets the endpoint_metadata_url' do
go
expect(assigns["endpoint_metadata_url"]).to eq(
diffs_metadata_project_json_merge_request_path(
project,
merge_request,
'json',
diff_head: true,
view: 'inline'))
end
context 'when diff files were cleaned' do context 'when diff files were cleaned' do
render_views render_views
...@@ -85,23 +97,6 @@ RSpec.describe Projects::MergeRequestsController do ...@@ -85,23 +97,6 @@ RSpec.describe Projects::MergeRequestsController do
end end
end end
context 'with `default_merge_ref_for_diffs` feature flag enabled' do
before do
stub_feature_flags(default_merge_ref_for_diffs: true)
go
end
it 'adds the diff_head parameter' do
expect(assigns["endpoint_metadata_url"]).to eq(
diffs_metadata_project_json_merge_request_path(
project,
merge_request,
'json',
diff_head: true,
view: 'inline'))
end
end
context 'when diff is missing' do context 'when diff is missing' do
render_views render_views
......
...@@ -79,27 +79,21 @@ describe('Compare diff version dropdowns', () => { ...@@ -79,27 +79,21 @@ describe('Compare diff version dropdowns', () => {
}; };
}; };
const assertVersions = (targetVersions) => { const assertVersions = (targetVersions, checkBaseVersion) => {
// base and head should be the last two versions in that order const targetLatestVersion = targetVersions[targetVersions.length - 1];
const targetBaseVersion = targetVersions[targetVersions.length - 2];
const targetHeadVersion = targetVersions[targetVersions.length - 1];
expect(targetVersions[0]).toEqual(expectedFirstVersion); expect(targetVersions[0]).toEqual(expectedFirstVersion);
expect(targetBaseVersion).toEqual(expectedBaseVersion);
expect(targetHeadVersion).toEqual(expectedHeadVersion); if (checkBaseVersion) {
expect(targetLatestVersion).toEqual(expectedBaseVersion);
} else {
expect(targetLatestVersion).toEqual(expectedHeadVersion);
}
}; };
afterEach(() => { afterEach(() => {
setWindowLocation(originalLocation); setWindowLocation(originalLocation);
}); });
it('base version selected', () => {
setupTest();
expectedBaseVersion.selected = true;
const targetVersions = getters.diffCompareDropdownTargetVersions(localState, getters);
assertVersions(targetVersions);
});
it('head version selected', () => { it('head version selected', () => {
setupTest(true); setupTest(true);
...@@ -126,6 +120,21 @@ describe('Compare diff version dropdowns', () => { ...@@ -126,6 +120,21 @@ describe('Compare diff version dropdowns', () => {
}); });
assertVersions(targetVersions); assertVersions(targetVersions);
}); });
describe('when state.mergeRequestDiff.head_version_path is null', () => {
beforeEach(() => {
localState.mergeRequestDiff.head_version_path = null;
});
it('base version selected', () => {
setupTest(true);
expectedBaseVersion.selected = true;
const targetVersions = getters.diffCompareDropdownTargetVersions(localState, getters);
assertVersions(targetVersions, true);
});
});
}); });
it('diffCompareDropdownSourceVersions', () => { it('diffCompareDropdownSourceVersions', () => {
......
...@@ -47,15 +47,5 @@ RSpec.describe MergeRequests::ReloadMergeHeadDiffService do ...@@ -47,15 +47,5 @@ RSpec.describe MergeRequests::ReloadMergeHeadDiffService do
expect(merge_request.reload.merge_head_diff).not_to eq(existing_merge_head_diff) expect(merge_request.reload.merge_head_diff).not_to eq(existing_merge_head_diff)
end end
end end
context 'when default_merge_ref_for_diffs feature flag is disabled' do
before do
stub_feature_flags(default_merge_ref_for_diffs: false)
end
it 'returns error' do
expect(subject[:status]).to eq(:error)
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment