Script and Workflows for automatic code formating#175
Script and Workflows for automatic code formating#175tquatmann merged 7 commits intostormchecker:masterfrom
Conversation
|
The |
|
Hi Tim, Thanks for this. The formatting rules look good to me. |
|
Yeah, I totally see the problem with the history. However, I somehow don't get why it helps to split these into two commits? Can you elaborate? I just learned there is an option for |
|
So if I look at the link you provided with the changes made, then git seems to have issues to map the lines adequately. Instead, it is making huge blocks of removed/added stuff. I dont think the .git_blame_ignore_revs will work. My guess/experience with git is that if you e.g. only do limited trailing whitespace changes (but not whitespace / line breaks inside a line) it handles it better. My hope would be that then the blocks that are deleted/added are smaller and thus more easy to understand the original source later. |
| clangFormatVersion: 12 | ||
| style: file | ||
| inplace: True | ||
| - uses: EndBug/add-and-commit@v4 |
There was a problem hiding this comment.
Maybe it is a bit safer to open a PR instead of directly pushing a new commit? There are Github actions for automatically opening PRs.
…irectly). Also, it adds relevant hashs to a .git-blame-ignore-revs.
This PR adds automatic code formatting facilities (using
clang-format).Code Formatting with Continuous Integration
Two GitHub workflows are added:
check-code-formatfails if the code is currently not formatted correctly. This action is triggered for every push and for every pull request.apply-code-formatactually applies the code formatting andcommitscreates a pull request (like this) containing all necessary changes. It also adds commit hashes to a new.git-blame-ignore-revsfile so thatgit blameremains (more or less) usable. Theapply-code-formathas to be triggered manually.All source code files in
./src. are considered, where the file.clang-format-ignorelists directory path patterns that are excluded. Currently, everything related to DFTs, POMDPs, and parametric models is excluded.Code Formatting Locally
This PR also adds a script for applying code formatting locally. The script can be invoked via a new make target. In the
builddirectory, we can now runmake formatto apply the formatting to all files (without committing anything).
Alternatively, most IDEs (e.g. CLion) can be configured in a way that code formatting is applied automatically when saving.
Our
.clang-formatconfiguration currently requiresclang-formatto be available in at least version12.Once this PR is merged, the plan is to (manually) trigger the
apply-code-formataction so that formatting will be applied to the existing codebase. This is what will happen.Further notes:
?w=1to the URL) so that we can see what the formatter is actually doing..clang-formatconfiguration that disables function definitions and if-statements in a single line.