From 1b6df7c396c3dcc3e77c61a10c04842e9f272e31 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Sun, 12 Jan 2020 18:43:18 +0000 Subject: [PATCH] Document the pre-commit hook modes. Signed-off-by: format 2020.01.12 [Exported from 4312fc435ec599e42fcd4ef8e5286772ab029d79] --- tools/format/README.md | 12 ++++++++---- tools/format/format.py | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/format/README.md b/tools/format/README.md index c1321b20..334b8112 100644 --- a/tools/format/README.md +++ b/tools/format/README.md @@ -13,10 +13,14 @@ Features: * Automated code styling of C/C++, Python, Java, SQL, JavaScript, HTML, CSS, go, and JSON files. - * Support for `.formatignore` files to mark files to be excluded from - formatting. The syntax of ignore files is similar to `.gitignore`, e.g. a - list of patterns to match, including (recursive) glob expansion, and - patterns beginning with `!` are un-ignored. + * Support for `.formatignore` files to mark files to be excluded from + formatting. The syntax of ignore files is similar to `.gitignore`, e.g. a + list of patterns to match, including (recursive) glob expansion, and + patterns beginning with `!` are un-ignored. + * A `--pre_commit` mode which formats files that have been staged for commit, + and stages changes. The commit is rejected if a partially-staged file is + modified. Enforce the use of pre-commit mode (and add a "Signed off" footer + to commits) by running `--install_pre_commit_hook`. * Persistent caching of "last modified" timestamps for files to minimize the amount of work done. * A process lock which prevents races when multiple formatters are launched diff --git a/tools/format/format.py b/tools/format/format.py index 7f0f50ac..9bac739e 100644 --- a/tools/format/format.py +++ b/tools/format/format.py @@ -27,6 +27,10 @@ formatting. The syntax of ignore files is similar to `.gitignore`, e.g. a list of patterns to match, including (recursive) glob expansion, and patterns beginning with `!` are un-ignored. + * A `--pre_commit` mode which formats files that have been staged for commit, + and stages changes. The commit is rejected if a partially-staged file is + modified. Enforce the use of pre-commit mode (and add a "Signed off" footer + to commits) by running `--install_pre_commit_hook`. * Persistent caching of "last modified" timestamps for files to minimize the amount of work done. * A process lock which prevents races when multiple formatters are launched