From bfbf1b8c9b3a0abba86474aeb72b950142723d73 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Tue, 14 Oct 2014 12:17:47 -0400 Subject: add better validation checks (part 1) This patch adds a script for validating YAML files, and replaces the existing JSON checks with one largely identical to the YAML check. This also provides a script that can be installed as a pre-commit hook that will perform this checks when you commit changes. You can install the hook by running tools/pre-commit-hook --install. Change-Id: Ib4742a9db062362cfa61d669c691151bc1ca376c --- tools/validate-json.sh | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) (limited to 'tools/validate-json.sh') diff --git a/tools/validate-json.sh b/tools/validate-json.sh index 35338e8d9..296ef781c 100755 --- a/tools/validate-json.sh +++ b/tools/validate-json.sh @@ -1,34 +1,3 @@ -#!/bin/bash -set -e -ret=0 +#!/bin/sh -# For MacOSX users the freebsd's mktemp by default behave diferently, -# installing the coreutils from brew would give you this but that would be -# renamed to gmktemp to don't conflict with the stand mktemp, so let just use -# that if available. -if type -p gmktemp &>/dev/null; then - TMPFILE=$(gmktemp) -else - TMPFILE=$(mktemp) -fi - -function clean { - rm -f ${TMPFILE} -} -trap clean EXIT - -linter=jsonlint -type -p jsonlint &>/dev/null || linter=python - -for f in $(find docker -type f -name '*.json');do - if [[ ${linter} == jsonlint ]];then - jsonlint -s ${f} >${TMPFILE} - egrep -q 'has errors$' ${TMPFILE} && { cat ${TMPFILE}; ret=1 ;} - else - python -m json.tool ${f} &>/dev/null || { echo "$f: has json errors"; ret=1; } - fi -done - -cat ${TMPFILE} - -exit ${ret} +true -- cgit v1.2.3