Installation
- For Mac OS X (simple installation of package current version 3.9):
- Using Homebrew
brew update; brew install clang-format
- Using prebuild packages with version equal or higher than 3.9 (http://llvm.org/releases/download.html)
- Build it by yourself …
- Using Homebrew
- For OpenSuse - using prebuild packages:
- For Ubuntu:
- Using apt-get
apt-get install clang-format
- Using apt-get
- For Fedora:
- Check prebuild rpms: http://llvm.org/releases/3.9.0/clang+llvm-3.9.0-x86_64-fedoraxxx.tar.xz
- Using Yum
yum install clang
(no separate package)
Clang-format git hook
Clang-format integration in Git is done from client side through git pre-commit hook that runs an clang-format style check only for .c, .cxx, .h, .cpp files that you modified during commit.
Features:- create a patch of the proposed style changes;
- git hook can provide a preview of possible modifications;
- user can select if to apply patch or not (through bash dialog window).
Important to know
We have our own .clang-format file in root of Git repository - there are some specific changes concerning length of line (120 symbols).
.Clang-format file should be automatically used by clang-format git hook.
How to install and use hook?
- Download or install clang-format, after please add binary location for clang-format in the $PATH
- Clone or pull master of repository VecGeom or GeantV
- Run:
sh hooks/setup-hook.sh
- …Write beautifull code…
- Add files
git add 'modified files'
- Commit files
git commit -m “[VECGEOM/GEANT-xx] My message”
(please don't forget to add JIRA numbers of issues that you are fixing, you will have JIRA git hook after clang-format hook) - Check proposed version of modification of file by clang-format
- Select please correct decision:
- "Do you want to install patch (Yes - commit with patch, No - commit without patch, Cancel - stop committing)? [Y/N/C]"
- IMPORTANT: Answer is case-sensitive: please write your choice with capital letters (Y, N , C)
Remarks
- Please don't forget that after clang-format hook, you also have JIRA hook that ask you to start your commit with [GEANT-xxx] and [VECGEOM-xxx]