From 020375d1e723339a95b86d0d3b8a8214b1cc144a Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 4 Dec 2015 13:14:27 +0100 Subject: Add linter to check for binaries accidentally added to repository This should catch mistakes like a703fbce20969e6f02e74fee76c0a9e22b513426. Adds an arcanist-external-json-linter submodule, which should eventually be mirrored on haskell.org resources. Test Plan: Validate Reviewers: thomie, hvr, austin Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D1515 --- .arc-linters/check-binaries.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 .arc-linters/check-binaries.py (limited to '.arc-linters/check-binaries.py') diff --git a/.arc-linters/check-binaries.py b/.arc-linters/check-binaries.py new file mode 100755 index 0000000000..ae007567fa --- /dev/null +++ b/.arc-linters/check-binaries.py @@ -0,0 +1,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) -- cgit v1.2.1