Commit 3bace174 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'id-remove-diff-compare-with-head-feature-flag' into 'master'

Enable minimal merge-ref diff by default

See merge request gitlab-org/gitlab!31325
parents a7efc44f 91d73233
......@@ -40,10 +40,7 @@ export const diffCompareDropdownTargetVersions = (state, getters) => {
};
};
if (gon.features?.diffCompareWithHead) {
return [...state.mergeRequestDiffs.slice(1).map(formatVersion), baseVersion, headVersion];
}
return [...state.mergeRequestDiffs.slice(1).map(formatVersion), baseVersion];
return [...state.mergeRequestDiffs.slice(1).map(formatVersion), baseVersion, headVersion];
};
export const diffCompareDropdownSourceVersions = (state, getters) => {
......
......@@ -26,7 +26,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
push_frontend_feature_flag(:code_navigation, @project)
push_frontend_feature_flag(:widget_visibility_polling, @project, default_enabled: true)
push_frontend_feature_flag(:merge_ref_head_comments, @project)
push_frontend_feature_flag(:diff_compare_with_head, @project)
push_frontend_feature_flag(:accessibility_merge_request_widget, @project)
end
......
......@@ -875,7 +875,7 @@ class MergeRequest < ApplicationRecord
# rubocop: enable CodeReuse/ServiceClass
def diffable_merge_ref?
Feature.enabled?(:diff_compare_with_head, target_project) && can_be_merged? && merge_ref_head.present?
can_be_merged? && merge_ref_head.present?
end
# Returns boolean indicating the merge_status should be rechecked in order to
......
---
title: Allow showing merge request diffs compared to current version of target branch
merge_request: 31325
author:
type: added
......@@ -57,7 +57,7 @@ source and target branch can be shown mixed together making it hard to
understand which changes are being added and which already exist in the
target branch.
In GitLab 12.10, we added an **experimental** comparison mode, which
In GitLab 12.10, we added a comparison mode, which
shows a diff calculated by simulating how it would look like once merged - a more accurate
representation of the changes rather than using the base of the two
branches. The new mode is available from the comparison target drop down
......@@ -67,26 +67,6 @@ current default comparison.
![Merge request versions compare HEAD](img/versions_compare_head_v12_10.png)
### Enable or disable `HEAD` comparison mode **(CORE ONLY)**
`HEAD` comparison mode is under development and not ready for production use. It is
deployed behind a feature flag that is **disabled by default**.
[GitLab administrators with access to the GitLab Rails console](../../../administration/troubleshooting/navigating_gitlab_via_rails_console.md#starting-a-rails-console-session)
can enable it for your instance. You're welcome to test it, but use it at your
own risk.
To enable it:
```ruby
Feature.enable(:diff_compare_with_head)
```
To disable it:
```ruby
Feature.disable(:diff_compare_with_head)
```
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
......
......@@ -18,7 +18,6 @@ describe('Compare diff version dropdowns', () => {
};
localState.targetBranchName = 'baseVersion';
localState.mergeRequestDiffs = diffsMockData;
gon.features = { diffCompareWithHead: true };
});
describe('selectedTargetIndex', () => {
......@@ -129,14 +128,6 @@ describe('Compare diff version dropdowns', () => {
});
assertVersions(targetVersions);
});
it('does not list head version if feature flag is not enabled', () => {
gon.features = { diffCompareWithHead: false };
setupTest();
const targetVersions = getters.diffCompareDropdownTargetVersions(localState, getters);
expect(targetVersions.find(version => version.isHead)).toBeUndefined();
});
});
it('diffCompareDropdownSourceVersions', () => {
......
......@@ -3836,40 +3836,28 @@ describe MergeRequest do
end
describe '#diffable_merge_ref?' do
context 'diff_compare_with_head enabled' do
context 'merge request can be merged' do
context 'merge_to_ref is not calculated' do
it 'returns true' do
expect(subject.diffable_merge_ref?).to eq(false)
end
end
context 'merge_to_ref is calculated' do
before do
MergeRequests::MergeToRefService.new(subject.project, subject.author).execute(subject)
end
it 'returns true' do
expect(subject.diffable_merge_ref?).to eq(true)
end
context 'merge request can be merged' do
context 'merge_to_ref is not calculated' do
it 'returns true' do
expect(subject.diffable_merge_ref?).to eq(false)
end
end
context 'merge request cannot be merged' do
it 'returns false' do
subject.mark_as_unchecked!
context 'merge_to_ref is calculated' do
before do
MergeRequests::MergeToRefService.new(subject.project, subject.author).execute(subject)
end
expect(subject.diffable_merge_ref?).to eq(false)
it 'returns true' do
expect(subject.diffable_merge_ref?).to eq(true)
end
end
end
context 'diff_compare_with_head disabled' do
before do
stub_feature_flags(diff_compare_with_head: { enabled: false, thing: subject.target_project })
end
context 'merge request cannot be merged' do
it 'returns false' do
subject.mark_as_unchecked!
expect(subject.diffable_merge_ref?).to eq(false)
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