Add linter to check for binaries accidentally added to repository
[ghc.git] / .arc-linters / check-binaries.py
1 #!/usr/bin/env python
2
3 # A linter to warn when binary files are added to the repository
4
5 import sys
6 import os
7 import json
8
9 path = sys.argv[1]
10 warnings = []
11 if os.path.isfile(path):
12 with open(path) as f:
13 if '\0' in f.read(8000):
14 warning = {
15 'severity': 'warning',
16 'message': 'This file appears to be a binary file; does it really belong in the repository?'
17 }
18 warnings.append(warning)
19
20 print json.dumps(warnings)