From 7a1c7a7dcd0c614ac6adff83738c1c2afede3a80 Mon Sep 17 00:00:00 2001 From: wuzewu Date: Mon, 7 Jan 2019 17:25:23 +0800 Subject: [PATCH] add a script to check code style --- scripts/check_code_style.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/check_code_style.sh diff --git a/scripts/check_code_style.sh b/scripts/check_code_style.sh new file mode 100755 index 00000000..682b9cd3 --- /dev/null +++ b/scripts/check_code_style.sh @@ -0,0 +1,20 @@ +#!/bin/bash +function abort(){ + echo "Your change doesn't follow PaddleHub's code style." 1>&2 + echo "Please use pre-commit to check what is wrong." 1>&2 + exit 1 +} + +trap 'abort' 0 +set -e + +cd $TRAVIS_BUILD_DIR +export PATH=/usr/bin:$PATH +pre-commit install + +if ! pre-commit run -a ; then + git diff + exit 1 +fi + +trap : 0 -- GitLab