-
Notifications
You must be signed in to change notification settings - Fork 1.5k
clang‐format updates
Elliot Lee edited this page Oct 17, 2024
·
2 revisions
https://github.com/XRPLF/rippled/pull/5157
For branches using clang-format versions prior to 18, it is necessary to make changes to update for clang-format-18.
Instructions:
- confirm the commit sha with changes in
.clang-format
settings
$ git log develop --oneline --graph
. . .
* decb3c178e Update clang-format settings
. . .
- cherry pick this one commit on your branch (with signature)
$ git cherry-pick decb3c178e -S
- confirm the instruction (from
develop
) to reformat the sources files
$ git show develop:.github/workflows/clang-format.yml | grep find | head -1
run: find include src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-${CLANG_VERSION} -i {} +
- make sure your
clang-format
is version 18.1.3 (and only this version; e.g. 18.1.6 will reformat the sources differently)
$ clang-format --version
Ubuntu clang-format version 18.1.3 (1ubuntu1)
- reformat source files in your branch with clang-format 18.1.3 and updated settings
$ find include src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format -i {} +
- commit new formatting (with signature)
$ git commit -m "Reformat code with clang-format-18" -S -i include/ src/
- actually merge develop into your branch. should merge cleanly.
$ git merge --no-ff develop -S
If you have the pre-commit hook on your machine, after you have brought both .clang-format
and .pre-commit-config.yaml
up-to-date with develop
(e.g. you have merged with or rebased on develop
), you can just run: pre-commit run --all-files
The earlier instructions are still useful if merging is tricky because your sources haven't been reformatted yet.
credit to Bronek.