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