summaryrefslogtreecommitdiff
path: root/.arc-linters/check-binaries.py
blob: ae007567faafc68527a9dccf7a45a6f22e3b5795 (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) as f:
        if '\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)