File tree Expand file tree Collapse file tree 3 files changed +51
-34
lines changed
Expand file tree Collapse file tree 3 files changed +51
-34
lines changed Original file line number Diff line number Diff line change @@ -144,29 +144,17 @@ to be run manually or with every commit:
144144 ```shell
145145 pipenv run pre-commit install
146146 ```
147- - Run manually before commit :
147+ - Run manually using helper dev script :
148148 ```shell
149- pipenv run pre-commit run -a
149+ ./dev/check.sh [FILE]
150+ ```
151+ If no file(s) are specified, then it runs against all files:
152+ ```shell
153+ ./dev/check.sh
150154 ```
1511553. _(Optional)_ review the configuration file:
152156 [`.pre-commit-config.yaml`](.pre-commit-config.yaml)
153157
154-
155- #### Using [`dev/tools.sh`][tools-sh] helper script
156-
157- The [`dev/tools.sh`][tools-sh] helper script runs the static analysis tools
158- (`black`, `flake8`, and `isort`):
159- ```shell
160- ./dev/tools.sh
161- ```
162-
163- It can also accept command-line arguments to specify specific files or
164- directories to check:
165- ```shell
166- ./dev/tools.sh PATH/TO/MY/FILE.PY
167- ```
168-
169- [tools-sh]: /dev/tools.sh
170158[pre-commit]: https://pre-commit.com/
171159
172160
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ #
3+ # Perform static analysis checks and reformat Python code using pre-commit
4+ #
5+ # ### SETUP ####################################################################
6+
7+ set -o errexit
8+ set -o errtrace
9+ set -o nounset
10+
11+ # shellcheck disable=SC2154
12+ trap ' _es=${?};
13+ printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
14+ printf " exited with a status of ${_es}\n";
15+ exit ${_es}' ERR
16+
17+ DIR_REPO=" $( cd -P -- " ${0%/* } /.." && pwd -P) "
18+ # https://en.wikipedia.org/wiki/ANSI_escape_code
19+ E0=" $( printf " \e[0m" ) " # reset
20+ E30=" $( printf " \e[30m" ) " # black foreground
21+ E107=" $( printf " \e[107m" ) " # bright white background
22+
23+ # ### FUNCTIONS ################################################################
24+
25+ print_header () {
26+ # Print 80 character wide black on white heading with time
27+ printf " ${E30}${E107} # %-70s$( date ' +%T' ) ${E0} \n" " ${@ } "
28+ }
29+
30+ # ### MAIN #####################################################################
31+
32+ cd " ${DIR_REPO} "
33+
34+ print_header ' pre-commit'
35+ echo ' See .pre-commit-config.yaml for pre-commit configuration.'
36+ if [[ -n " ${1:- } " ]]
37+ then
38+ # Run on files specified on command line
39+ # shellcheck disable=SC2068
40+ pipenv run pre-commit run --files ${@:- }
41+ else
42+ # Run on all files
43+ pipenv run pre-commit run --all-files
44+ fi
45+ echo
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments