Commit 020375d1 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

Add linter to check for binaries accidentally added to repository

This should catch mistakes like
a703fbce.

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
parent d4bf8632
Subproject commit 85ece0f8653e7b1e7de6024d372cfeaf36ab5fa9
#!/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)
{
"project.name" : "ghc",
"repository.callsign" : "GHC",
"phabricator.uri" : "https://phabricator.haskell.org"
"phabricator.uri" : "https://phabricator.haskell.org",
"load": [
".arc-linters/arcanist-external-json-linter"
]
}
......@@ -52,6 +52,10 @@
"severity": {
"2": "disabled"
}
},
"check-binaries": {
"type": "external-json",
"external-json.script": "python .arc-linters/check-binaries.py"
}
},
......
......@@ -115,3 +115,6 @@
path = libffi-tarballs
url = ../libffi-tarballs.git
ignore = none
[submodule ".arc-linters/arcanist-external-json-linter"]
path = .arc-linters/arcanist-external-json-linter
url = https://github.com/bgamari/arcanist-external-json-linter.git
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment