We have now clang format hooks/extension for hg and git.

Both work in the same way: at commit phase, they will automatically run "mach clang-format <https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style/Formatting_C++_Code_With_clang-format>" (which is now executing in parallel <https://bugzilla.mozilla.org/show_bug.cgi?id=1521772>) on the files added as part of the commit operation. The reformatting will be done also during a commit --amend.

The hg extension (provided by version-control-tools) is automatically installed as part of the mach bootstrap process or can be done by hand by adding the following line in .hgrc:

format-source = ~/.mozbuild/version-control-tools/hgext/format-source


For git, running this command should be enough:

$ ln -s $(pwd)/tools/lint/hooks_clang_format.py .git/hooks/pre-commit


However, for git, because of limitations in this vcs, we aren't able to manage the git add -p case for now.


The goal is to have more and more people use these hooks to avoid the task of regularly reformatting the tree <https://bugzilla.mozilla.org/show_bug.cgi?id=1519636>.


Bugs should be reported here :

https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox%20Build%20System&component=Lint%20and%20Formatting


Implementations:

hg: https://hg.mozilla.org/hgcustom/version-control-tools/file/tip/hgext/clang-format/__init__.py

git: https://hg.mozilla.org/mozilla-central/file/tip/tools/lint/hooks_clang_format.py

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to