Commit 8a96d93e authored by Douwe Maan's avatar Douwe Maan

Merge branch '8215-only-allow-ruby-prepend-ee' into 'master'

Only allow Ruby to have extra prepend line

Closes #8215

See merge request gitlab-org/gitlab-ee!8226
parents d373c594 89f0711b
......@@ -13,14 +13,18 @@ updated_numstat = updated_diff_numstat(base.ce_head, base.ee_head)
offenses = updated_numstat.select do |file, updated_delta|
current_delta = current_numstat[file]
more_lines =
current_delta &&
updated_delta > current_delta &&
more_lines = updated_delta > current_delta
allow_prepend_line =
# Don't complain if we're just adding 1 or 2 more lines, which could be
# `prepend EE::Module` and a blank line that we want.
!(current_delta == 0 && updated_delta <= 2)
!(current_delta == 0 && updated_delta <= 2) ||
# We only allow Ruby files to have prepend line
!file.end_with?('.rb')
more_lines && !WHITELIST.any? { |pattern| Dir.glob(pattern).include?(file) }
more_lines &&
allow_prepend_line &&
!WHITELIST.any? { |pattern| Dir.glob(pattern).include?(file) }
end
if offenses.empty?
......
......@@ -278,7 +278,7 @@ module EESpecificCheck
def scan_diff_numstat(numstat)
numstat.scan(/(\d+)\s+(\d+)\s+(.+)/)
.each_with_object({}) do |(added, deleted, file), result|
.each_with_object(Hash.new(0)) do |(added, deleted, file), result|
result[file] = added.to_i + deleted.to_i
end
end
......
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