From 0da144f4d48d7a423b8f61cd178bb41346083107 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 13 Jul 2018 20:19:31 +0800 Subject: tools: add `make format-cpp` to run clang-format on C++ diffs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds a `make format-cpp` shortcut to the Makefile that runs clang-format on the C++ diffs, and a `make format-cpp-build` to install clang-format from npm. To format staged changes: ``` $ make format-cpp ``` To format HEAD~1...HEAD (latest commit): ``` $ CLANG_FORMAT_START=`git rev-parse HEAD~1` make format-cpp ``` To format diff between master and current branch head (master...HEAD): ``` $ CLANG_FORMAT_START=master make format-cpp ``` Most of the .clang-format file comes from running ``` $ clang-format --dump-config --style=Google ``` with clang-format built with llvm/trunk 328768 (npm version 1.2.3) The clang-format version is fixed because different version of clang-format may format the files differently. PR-URL: https://github.com/nodejs/node/pull/21997 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Michaƫl Zasso --- .gitignore | 1 + 1 file changed, 1 insertion(+) (limited to '.gitignore') diff --git a/.gitignore b/.gitignore index 1d901b3a69..255a4c5a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ !test/fixtures/**/.* !tools/node_modules/**/.* !tools/doc/node_modules/**/.* +!.clang-format !.editorconfig !.eslintignore !.eslintrc.js -- cgit v1.2.3