Commit beac214b authored by Kerri Miller's avatar Kerri Miller

Extract entry parsing by flagging

parent 9d7def72
...@@ -13,7 +13,7 @@ module Gitlab ...@@ -13,7 +13,7 @@ module Gitlab
end end
def parsed_data def parsed_data
@parsed_data ||= sectional_codeowners? ? get_parsed_sectional_data : get_parsed_data @parsed_data ||= get_parsed_data
end end
def empty? def empty?
...@@ -21,10 +21,22 @@ module Gitlab ...@@ -21,10 +21,22 @@ module Gitlab
end end
def entry_for_path(path) def entry_for_path(path)
return sectional_entry_for_path(path) if sectional_codeowners?
path = "/#{path}" unless path.start_with?('/') path = "/#{path}" unless path.start_with?('/')
if sectional_codeowners?
sectional_entry_for_path(path)
else
non_sectional_entry_for_path(path)
end
end
def path
@blob&.path
end
private
def non_sectional_entry_for_path(path)
matching_pattern = parsed_data.keys.reverse.detect do |pattern| matching_pattern = parsed_data.keys.reverse.detect do |pattern|
path_matches?(pattern, path) path_matches?(pattern, path)
end end
...@@ -33,7 +45,6 @@ module Gitlab ...@@ -33,7 +45,6 @@ module Gitlab
end end
def sectional_entry_for_path(path) def sectional_entry_for_path(path)
path = "/#{path}" unless path.start_with?('/')
matches = [] matches = []
parsed_data.each do |_, section_entries| parsed_data.each do |_, section_entries|
...@@ -47,12 +58,6 @@ module Gitlab ...@@ -47,12 +58,6 @@ module Gitlab
matches matches
end end
def path
@blob&.path
end
private
def data def data
if @blob && !@blob.binary? if @blob && !@blob.binary?
@blob.data @blob.data
...@@ -62,6 +67,14 @@ module Gitlab ...@@ -62,6 +67,14 @@ module Gitlab
end end
def get_parsed_data def get_parsed_data
if sectional_codeowners?
get_parsed_sectional_data
else
get_parsed_non_sectional_data
end
end
def get_parsed_non_sectional_data
parsed = {} parsed = {}
data.lines.each do |line| data.lines.each do |line|
......
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