[commit: ghc] master: Add linter to check for binaries accidentally added to repository (020375d)

git at git.haskell.org git at git.haskell.org
Fri Dec 4 16:31:27 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/020375d1e723339a95b86d0d3b8a8214b1cc144a/ghc

>---------------------------------------------------------------

commit 020375d1e723339a95b86d0d3b8a8214b1cc144a
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Fri Dec 4 13:14:27 2015 +0100

    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


>---------------------------------------------------------------

020375d1e723339a95b86d0d3b8a8214b1cc144a
 .arc-linters/arcanist-external-json-linter |  1 +
 .arc-linters/check-binaries.py             | 20 ++++++++++++++++++++
 .arcconfig                                 |  6 +++++-
 .arclint                                   |  4 ++++
 .gitmodules                                |  3 +++
 5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/.arc-linters/arcanist-external-json-linter b/.arc-linters/arcanist-external-json-linter
new file mode 160000
index 0000000..85ece0f
--- /dev/null
+++ b/.arc-linters/arcanist-external-json-linter
@@ -0,0 +1 @@
+Subproject commit 85ece0f8653e7b1e7de6024d372cfeaf36ab5fa9
diff --git a/.arc-linters/check-binaries.py b/.arc-linters/check-binaries.py
new file mode 100755
index 0000000..ae00756
--- /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)
diff --git a/.arcconfig b/.arcconfig
index b9c3932..c886789 100644
--- a/.arcconfig
+++ b/.arcconfig
@@ -1,5 +1,9 @@
 {
   "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"
+  ]
 }
diff --git a/.arclint b/.arclint
index 8f83776..1b13507 100644
--- a/.arclint
+++ b/.arclint
@@ -52,6 +52,10 @@
       "severity": {
         "2": "disabled"
       }
+    },
+    "check-binaries": {
+      "type": "external-json",
+      "external-json.script": "python .arc-linters/check-binaries.py"
     }
   },
 
diff --git a/.gitmodules b/.gitmodules
index 662f6d6..0d88e01 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -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



More information about the ghc-commits mailing list