Skip to content
代码片段 群组 项目
提交 bc048d82 编辑于 作者: Sean McGivern's avatar Sean McGivern
浏览文件

Merge branch '12137-ignore-section-headers-in-legacy-parsing-of-codeowners-file' into 'master'

Skip section headers in legacy file parsing

See merge request gitlab-org/gitlab!32270
No related branches found
No related tags found
无相关合并请求
...@@ -80,7 +80,7 @@ def get_parsed_non_sectional_data ...@@ -80,7 +80,7 @@ def get_parsed_non_sectional_data
data.lines.each do |line| data.lines.each do |line|
line = line.strip line = line.strip
next if skip?(line) next if skip?(line) || line.match?(SECTION_HEADER_REGEX)
extract_entry_and_populate_parsed_data(line, parsed) extract_entry_and_populate_parsed_data(line, parsed)
end end
......
...@@ -37,6 +37,21 @@ def owner_line(pattern) ...@@ -37,6 +37,21 @@ def owner_line(pattern)
expect(owner_line('/**/LICENSE')).to include('legal', 'janedoe@gitlab.com') expect(owner_line('/**/LICENSE')).to include('legal', 'janedoe@gitlab.com')
end end
context "when CODEOWNERS file contains multiple sections" do
let(:file_content) do
File.read(Rails.root.join("ee", "spec", "fixtures", "sectional_codeowners_example"))
end
let(:patterns) { ["[Documentation]", "[Database]"] }
let(:paths) { ["/**/[Documentation]", "/**/[Database]"] }
it "skips section headers when parsing" do
expect(file.parsed_data.keys).not_to include(*paths)
expect(file.parsed_data.values.any? { |e| patterns.include?(e.pattern) }).to be_falsey
expect(file.parsed_data.values.any? { |e| e.owner_line.blank? }).to be_falsey
end
end
context "when feature flag `:sectional_codeowners` is enabled" do context "when feature flag `:sectional_codeowners` is enabled" do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
...@@ -44,7 +59,7 @@ def owner_line(pattern) ...@@ -44,7 +59,7 @@ def owner_line(pattern)
stub_feature_flags(sectional_codeowners: true) stub_feature_flags(sectional_codeowners: true)
end end
shared_examples_for "creates expected parsed results" do shared_examples_for "creates expected parsed sectional results" do
it "is a hash sorted by sections without duplicates" do it "is a hash sorted by sections without duplicates" do
data = file.parsed_data data = file.parsed_data
...@@ -102,7 +117,7 @@ def owner_line(pattern) ...@@ -102,7 +117,7 @@ def owner_line(pattern)
File.read(Rails.root.join("ee", "spec", "fixtures", "sectional_codeowners_example")) File.read(Rails.root.join("ee", "spec", "fixtures", "sectional_codeowners_example"))
end end
it_behaves_like "creates expected parsed results" it_behaves_like "creates expected parsed sectional results"
end end
context "when CODEOWNERS file contains multiple sections with mixed-case names" do context "when CODEOWNERS file contains multiple sections with mixed-case names" do
...@@ -110,7 +125,7 @@ def owner_line(pattern) ...@@ -110,7 +125,7 @@ def owner_line(pattern)
File.read(Rails.root.join("ee", "spec", "fixtures", "mixed_case_sectional_codeowners_example")) File.read(Rails.root.join("ee", "spec", "fixtures", "mixed_case_sectional_codeowners_example"))
end end
it_behaves_like "creates expected parsed results" it_behaves_like "creates expected parsed sectional results"
end end
end end
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册