Commit cb3ca8c6 authored by Kerri Miller's avatar Kerri Miller

Cleanup section string extraction

parent 499d4435
...@@ -60,7 +60,7 @@ module Gitlab ...@@ -60,7 +60,7 @@ module Gitlab
def get_parsed_sectional_data def get_parsed_sectional_data
parsed = {} parsed = {}
section = ::Gitlab::CodeOwners::Entry::DEFAULT_SECTION.downcase section = ::Gitlab::CodeOwners::Entry::DEFAULT_SECTION
parsed[section] = {} parsed[section] = {}
...@@ -70,13 +70,13 @@ module Gitlab ...@@ -70,13 +70,13 @@ module Gitlab
next if skip?(line) next if skip?(line)
if line.starts_with?('[') && line.end_with?(']') if line.starts_with?('[') && line.end_with?(']')
section = line[1...-1].downcase section = line[1...-1].strip
parsed[section] ||= {} parsed[section] ||= {}
next next
end end
extract_entry_and_populate_parsed(line, parsed, section.downcase) extract_entry_and_populate_parsed(line, parsed, section)
end end
parsed parsed
......
...@@ -52,7 +52,7 @@ describe Gitlab::CodeOwners::File do ...@@ -52,7 +52,7 @@ describe Gitlab::CodeOwners::File do
data = file.parsed_data data = file.parsed_data
expect(data.keys.length).to eq(1) expect(data.keys.length).to eq(1)
expect(data.keys).to contain_exactly(::Gitlab::CodeOwners::Entry::DEFAULT_SECTION.downcase) expect(data.keys).to contain_exactly(::Gitlab::CodeOwners::Entry::DEFAULT_SECTION)
end end
context "when CODEOWNERS file contains multiple sections" do context "when CODEOWNERS file contains multiple sections" do
...@@ -66,13 +66,13 @@ describe Gitlab::CodeOwners::File do ...@@ -66,13 +66,13 @@ describe Gitlab::CodeOwners::File do
data = file.parsed_data data = file.parsed_data
expect(data.keys.length).to eq(3) expect(data.keys.length).to eq(3)
expect(data.keys).to contain_exactly("codeowners", "documentation", "database") expect(data.keys).to contain_exactly("codeowners", "Documentation", "Database")
end end
where(:section, :patterns) do where(:section, :patterns) do
"codeowners" | ["/**/ee/**/*"] "codeowners" | ["/**/ee/**/*"]
"documentation" | ["/**/README.md", "/**/ee/docs", "/**/docs"] "Documentation" | ["/**/README.md", "/**/ee/docs", "/**/docs"]
"database" | ["/**/README.md", "/**/model/db"] "Database" | ["/**/README.md", "/**/model/db"]
end end
with_them do with_them 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