Commit cb3ca8c6 authored by Kerri Miller's avatar Kerri Miller

Cleanup section string extraction

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