-
-
Notifications
You must be signed in to change notification settings - Fork 284
Creating a pre commit hook for clang format
The best way to do this is to ask your package manager which versions of clang-format
. are available.
From a terminal, enter the following:
apt-get update
apt-cache search clang-format
This will present you with a list of available versions. Pick one, and run
apt-get install clang-format-xxx
replacing clang-format-xxx
with the full name of the version you picked.
From a terminal, enter the following:
yum search clang-format
This will present you with a list of available versions. Pick one, and run
yum install clang-format-xxx
replacing clang-format-xxx
with the full name of the version you picked.
download our pre-commit script from here, and save it to the root directory of the repository clone to which you wish to apply the hook. Then, navigate to the repository's root directory and rename the downloaded file to .git/hooks/pre-commit
.
Alternatively, do it entirely from a terminal:
cd corelibs-arduino101-fork
curl https://gist.githubusercontent.com/eriknyquist/d8d3c14406a76bd7d9516a3aaaa3423e/raw > .git/hooks/pre-commit
download our style file from here, and save it to the root directory of the repository clone to which you wish to apply the hook. Then, navigate to the repository's root directory and rename the downloaded file to .clang-format
.
Alternatively, do it entirely from a terminal:
cd corelibs-arduino101-fork
curl https://gist.githubusercontent.com/eriknyquist/e2f6ea988d007bdd448ac5b11edab1c6/raw > .clang-format
That's it! Next time you type git commit
, your changes will be automatically formatted with clang-format
.