From 38ec0677c5711e4392740f17a2b9d9442600016b Mon Sep 17 00:00:00 2001 From: jiangjiajun Date: Thu, 28 Mar 2019 13:58:39 +0800 Subject: [PATCH] add pre-commit --- .pre-commit-config.yaml | 27 +++++++++++++++++++++++++++ .style.yapf | 3 +++ commit-prepare.sh | 6 ++++++ 3 files changed, 36 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 .style.yapf create mode 100644 commit-prepare.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..21bab1f --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +- repo: local + hooks: + - id: yapf + name: yapf + entry: yapf + language: system + args: [-i, --style .style.yapf] + files: \.py$ + +- repo: https://github.com/pre-commit/pre-commit-hooks + sha: a11d9314b22d8f8c7556443875b731ef05965464 + hooks: + - id: check-merge-conflict + - id: check-symlinks + - id: end-of-file-fixer + - id: trailing-whitespace + - id: detect-private-key + - id: check-symlinks + - id: check-added-large-files +- repo: local + hooks: + - id: copyright_checker + name: copyright_checker + entry: python ./.copyright.hook + language: system + files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$ + exclude: (?!.*third_party)^.*$ diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 0000000..4741fb4 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,3 @@ +[style] +based_on_style = pep8 +column_limit = 80 diff --git a/commit-prepare.sh b/commit-prepare.sh new file mode 100644 index 0000000..faa217e --- /dev/null +++ b/commit-prepare.sh @@ -0,0 +1,6 @@ +path=$(cd `dirname $0`; pwd) +cd $path + +pip install pre-commit +pip install yapf +pre-commit install -- GitLab