Commit 41538242 authored by Kerri Miller's avatar Kerri Miller

Add :sectional_codeowners feature flag

This shouldn't be enabled at all for now.
parent 9f69b063
...@@ -40,6 +40,10 @@ module Gitlab ...@@ -40,6 +40,10 @@ module Gitlab
end end
def get_parsed_data def get_parsed_data
if Feature.enabled?(:sectional_codeowners, default_enabled: false)
return get_parsed_sectional_data
end
parsed = {} parsed = {}
data.lines.each do |line| data.lines.each do |line|
...@@ -57,6 +61,10 @@ module Gitlab ...@@ -57,6 +61,10 @@ module Gitlab
parsed parsed
end end
def get_parsed_sectional_data
{}
end
def normalize_pattern(pattern) def normalize_pattern(pattern)
# Remove `\` when escaping `\#` # Remove `\` when escaping `\#`
pattern = pattern.sub(/\A\\#/, '#') pattern = pattern.sub(/\A\\#/, '#')
......
...@@ -32,6 +32,8 @@ describe 'Projects > Merge Requests > User edits a merge request' do ...@@ -32,6 +32,8 @@ describe 'Projects > Merge Requests > User edits a merge request' do
let(:ruby_owner) { create(:user, username: 'ruby-owner') } let(:ruby_owner) { create(:user, username: 'ruby-owner') }
before do before do
stub_feature_flags(sectional_codeowners: false)
project.add_developer(ruby_owner) project.add_developer(ruby_owner)
project.repository.create_file(user, 'ruby.rb', '# a ruby file', project.repository.create_file(user, 'ruby.rb', '# a ruby file',
message: 'Add a ruby file', message: 'Add a ruby file',
......
...@@ -22,6 +22,7 @@ describe 'File blob > Code owners', :js do ...@@ -22,6 +22,7 @@ describe 'File blob > Code owners', :js do
context 'when the feature is available' do context 'when the feature is available' do
before do before do
stub_licensed_features(code_owners: true) stub_licensed_features(code_owners: true)
stub_feature_flags(sectional_codeowners: false)
end end
it 'shows the code owners related to a file' do it 'shows the code owners related to a file' do
......
...@@ -56,6 +56,10 @@ describe Gitlab::Checks::DiffCheck do ...@@ -56,6 +56,10 @@ describe Gitlab::Checks::DiffCheck do
end end
context 'and the user is not listed as a codeowner' do context 'and the user is not listed as a codeowner' do
before do
stub_feature_flags(sectional_codeowners: false)
end
it "returns an error message" do it "returns an error message" do
expect { diff_check.validate! }.to raise_error do |error| expect { diff_check.validate! }.to raise_error do |error|
expect(error).to be_a(Gitlab::GitAccess::ForbiddenError) expect(error).to be_a(Gitlab::GitAccess::ForbiddenError)
...@@ -81,6 +85,10 @@ describe Gitlab::Checks::DiffCheck do ...@@ -81,6 +85,10 @@ describe Gitlab::Checks::DiffCheck do
end end
context "and the user is not listed as a code owner" do context "and the user is not listed as a code owner" do
before do
stub_feature_flags(sectional_codeowners: false)
end
it "returns an error message" do it "returns an error message" do
expect(validation_result).to include("Pushes to protected branches") expect(validation_result).to include("Pushes to protected branches")
end end
......
...@@ -14,6 +14,10 @@ describe Gitlab::CodeOwners::File do ...@@ -14,6 +14,10 @@ describe Gitlab::CodeOwners::File do
subject(:file) { described_class.new(blob) } subject(:file) { described_class.new(blob) }
before do
stub_feature_flags(sectional_codeowners: false)
end
describe '#parsed_data' do describe '#parsed_data' do
def owner_line(pattern) def owner_line(pattern)
file.parsed_data[pattern].owner_line file.parsed_data[pattern].owner_line
...@@ -32,6 +36,18 @@ describe Gitlab::CodeOwners::File do ...@@ -32,6 +36,18 @@ describe Gitlab::CodeOwners::File do
it 'allows usernames and emails' do it 'allows usernames and emails' do
expect(owner_line('/**/LICENSE')).to include('legal', 'janedoe@gitlab.com') expect(owner_line('/**/LICENSE')).to include('legal', 'janedoe@gitlab.com')
end end
context "when feature flag `:sectional_codeowners` is enabled" do
before do
stub_feature_flags(sectional_codeowners: true)
end
it "passes the call to #get_parsed_sectional_data" do
expect(file).to receive(:get_parsed_sectional_data).and_return({})
expect(file.parsed_data).to be_empty
end
end
end end
describe '#empty?' do describe '#empty?' do
......
...@@ -39,6 +39,10 @@ describe Gitlab::CodeOwners::Loader do ...@@ -39,6 +39,10 @@ describe Gitlab::CodeOwners::Loader do
let(:expected_entry) { Gitlab::CodeOwners::Entry.new('docs/CODEOWNERS', '@owner-1 owner2@gitlab.org @owner-3 @documentation-owner') } let(:expected_entry) { Gitlab::CodeOwners::Entry.new('docs/CODEOWNERS', '@owner-1 owner2@gitlab.org @owner-3 @documentation-owner') }
let(:first_entry) { loader.entries.first } let(:first_entry) { loader.entries.first }
before do
stub_feature_flags(sectional_codeowners: false)
end
it 'returns entries for the matched line' do it 'returns entries for the matched line' do
expect(loader.entries).to contain_exactly(expected_entry) expect(loader.entries).to contain_exactly(expected_entry)
end end
...@@ -121,6 +125,10 @@ describe Gitlab::CodeOwners::Loader do ...@@ -121,6 +125,10 @@ describe Gitlab::CodeOwners::Loader do
end end
describe '#members' do describe '#members' do
before do
stub_feature_flags(sectional_codeowners: false)
end
it 'returns users mentioned for the passed path' do it 'returns users mentioned for the passed path' do
expect(loader.members).to contain_exactly(owner_1, email_owner, documentation_owner) expect(loader.members).to contain_exactly(owner_1, email_owner, documentation_owner)
end end
...@@ -143,6 +151,10 @@ describe Gitlab::CodeOwners::Loader do ...@@ -143,6 +151,10 @@ describe Gitlab::CodeOwners::Loader do
end end
describe '#empty_code_owners?' do describe '#empty_code_owners?' do
before do
stub_feature_flags(sectional_codeowners: false)
end
context 'when file does not exist' do context 'when file does not exist' do
let(:codeowner_blob) { nil } let(:codeowner_blob) { nil }
......
...@@ -26,6 +26,7 @@ describe Gitlab::CodeOwners do ...@@ -26,6 +26,7 @@ describe Gitlab::CodeOwners do
context 'when the feature is available' do context 'when the feature is available' do
before do before do
stub_licensed_features(code_owners: true) stub_licensed_features(code_owners: true)
stub_feature_flags(sectional_codeowners: false)
end end
it 'returns users for a blob' do it 'returns users for a blob' do
...@@ -59,6 +60,7 @@ describe Gitlab::CodeOwners do ...@@ -59,6 +60,7 @@ describe Gitlab::CodeOwners do
before do before do
stub_licensed_features(code_owners: true) stub_licensed_features(code_owners: true)
stub_feature_flags(sectional_codeowners: false)
end end
it "return equivalent results" do it "return equivalent results" do
...@@ -89,6 +91,7 @@ describe Gitlab::CodeOwners do ...@@ -89,6 +91,7 @@ describe Gitlab::CodeOwners do
context 'when the feature is available' do context 'when the feature is available' do
before do before do
stub_licensed_features(code_owners: true) stub_licensed_features(code_owners: true)
stub_feature_flags(sectional_codeowners: false)
end end
it 'returns owners for merge request' do it 'returns owners for merge request' do
......
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