D24568: Provide clang-format target with a KDE Frameworks style file

Milian Wolff noreply at phabricator.kde.org
Sun Oct 13 20:24:26 BST 2019


mwolff added a comment.


  In D24568#545942 <https://phabricator.kde.org/D24568#545942>, @cullmann wrote:
  
  > In D24568#545736 <https://phabricator.kde.org/D24568#545736>, @apol wrote:
  >
  > > I'm not sure how this works, but would it be possible to have a target that only works on a patch? You usually want to make sure what you modified didn't diverge from the code.
  >
  >
  > I think there is some hack around that:
  >  http://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting
  >
  > But actually, if your sources are already clang-formatted, you just need to run the clang-format target once before you commit, the your new code will be the only thing altered.
  
  
  For our projects at work where we have the liberty to dictate the coding style, we also use clang format. To do that properly, we have a pre-commit check locally and then a gerrit bot similar to the Qt coding style bot which checks the formatting introduced by a patch. This way, one can be sure that the style doesn't deteriorate over time.
  
  Some links on that matter:
  
  - https://github.com/nghttp2/nghttp2/blob/master/pre-commit is what I use to check my commits, there are probably other, better hooks available somewhere, but this one has suited me well so far
  - when the hook complains, I run `git clang-format` which is part of the clang package that also ships clang-format on ArchLinux
  
  I guess the commit hook can also be used for a server check, but I'm not sure how this is done with gerrit for us, or how one would do it with phabricator/gitlab for KDE.
  
  Anyhow: big +1 form my side for using clang-format for all of KDE (eventually) and KDE frameworks in the near future as a starting point.

REPOSITORY
  R240 Extra CMake Modules

REVISION DETAIL
  https://phabricator.kde.org/D24568

To: cullmann, #frameworks
Cc: mwolff, ochurlaud, nalvarez, kossebau, aacid, davidedmundson, dhaumann, apol, ognarb, kde-frameworks-devel, kde-buildsystem, LeGast00n, GB_2, bencreasy, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-buildsystem/attachments/20191013/031b0c51/attachment-0001.html>


More information about the Kde-buildsystem mailing list