fix for multiple copyrights

This commit is contained in:
Ben Balter 2017-03-01 16:12:22 -05:00
parent a22b239cd1
commit 48b44457f0
No known key found for this signature in database
GPG Key ID: DBB67C246AD356C4
2 changed files with 13 additions and 2 deletions

View File

@ -60,7 +60,9 @@ module Licensee
return unless content
@content_normalized ||= begin
string = content_without_title_and_version.downcase
string = strip_copyright(string)
while string =~ Matchers::Copyright::REGEX
string = strip_copyright(string)
end
string = strip_hrs(string)
string, _partition, _instructions = string.partition(END_OF_TERMS_REGEX)
strip_whitespace(string)
@ -88,7 +90,7 @@ module Licensee
end
def strip_copyright(string)
string.gsub(/\A#{Matchers::Copyright::REGEX}$/i, '').strip
string.gsub(Matchers::Copyright::REGEX, '').strip
end
# Strip HRs from MPL

View File

@ -116,5 +116,14 @@ EOS
expect(normalized_content).to eql('foo')
end
end
context 'multiple copyrights' do
let(:content) { "Copyright 2016 Ben Balter\nCopyright 2017 Bob\nFoo" }
it 'strips multiple copyrights' do
expect(normalized_content).to_not match('Ben')
expect(normalized_content).to eql('foo')
end
end
end
end