# HG changeset patch # User Sjoerd Mullender <sjoerd@acm.org> # Date 1425649279 -3600 # Node ID 1ba95b6130d4d6964e04873cf97a0a8e93620276 # Parent 42b21d1a4e84b39616acafb6f6aa11237bebf4e0 Allow binary files to not end in newline. diff -r 42b21d1a4e84 -r 1ba95b6130d4 check_whitespace.py --- a/check_whitespace.py Wed Nov 05 09:33:14 2014 +0100 +++ b/check_whitespace.py Fri Mar 06 14:41:19 2015 +0100 @@ -17,6 +17,23 @@ ''' import re +import os + +binary_suffixes = ( + '.bam', + '.bmp', + '.bz2', + '.chm', + '.cpl', + '.dia', + '.dll', + '.gz', + '.ico', + '.pdf', + '.png', + '.rtf', + '.zip', +) def trailing_whitespace(difflines): linenum = 0 @@ -61,7 +78,8 @@ elif adding \ and not islink \ and line.startswith(r'\ No newline at end of file') \ - and not filename.endswith('vertoo.data'): + and not filename.endswith('vertoo.data') \ + and not os.path.splitext(filename)[1] in binary_suffixes: adding = False yield filename, linenum, 'no newline at end of file' # hunk body - check for an added line with bad whitespace