Skip to content
Snippets Groups Projects
Verified Commit add9e1cb authored by Lars Bilke's avatar Lars Bilke
Browse files

[pre-commit] Added clang-format.

parent 8c13a49c
No related branches found
No related tags found
No related merge requests found
...@@ -46,3 +46,7 @@ repos: ...@@ -46,3 +46,7 @@ repos:
- id: cmake-lint - id: cmake-lint
additional_dependencies: ["cmakelang[YAML]"] additional_dependencies: ["cmakelang[YAML]"]
exclude: "scripts/cmake/jedbrown/.*|PackagingMacros.cmake|conan.cmake|CPM.cmake|FindFilesystem.cmake|ConanSetup.cmake|BuildExternalProject.cmake" exclude: "scripts/cmake/jedbrown/.*|PackagingMacros.cmake|conan.cmake|CPM.cmake|FindFilesystem.cmake|ConanSetup.cmake|BuildExternalProject.cmake"
- repo: git://github.com/doublify/pre-commit-clang-format
rev: 62302476d0da01515660132d76902359bed0f782
hooks:
- id: clang-format
pre commit: pre commit:
stage: preparation stage: preparation
image: $PRECOMMIT_IMAGE image: $PRECOMMIT_IMAGE
needs: [ ci_images ] needs: [ci_images]
script: script:
- pre-commit install - pre-commit install
- pre-commit run --all-files - pre-commit run --all-files
- git diff --check `git merge-base origin/master HEAD` HEAD -- . ':!*.md' ':!*.pandoc' ':!*.asc' ':!*.dat' ':!*.ts' - git diff --check `git merge-base origin/master HEAD` HEAD -- . ':!*.md' ':!*.pandoc' ':!*.asc' ':!*.dat' ':!*.ts'
after_script:
- git diff
...@@ -3,5 +3,5 @@ FROM python:slim ...@@ -3,5 +3,5 @@ FROM python:slim
RUN pip install pre-commit==2.7.1 RUN pip install pre-commit==2.7.1
CMD ["bash"] CMD ["bash"]
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends git gcc g++ \ && apt-get install -y --no-install-recommends git gcc g++ clang-format \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
...@@ -9,7 +9,7 @@ weight = 1014 ...@@ -9,7 +9,7 @@ weight = 1014
parent = "development-workflows" parent = "development-workflows"
+++ +++
We aim for a consistent and readable coding style. You do not need to worry about styling if you use the right tools we present in the following. We aim for a consistent and readable coding style. You do not need to worry about styling if you use the right tools we present in the following. Please also enable [pre-commit]({{< ref "setup-fork.md#optional-enable-git-commit-hooks" >}}) in your repository to have these check run automatically for you on every commit!
## C++ ## C++
...@@ -21,8 +21,6 @@ Use [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html). It can be ad ...@@ -21,8 +21,6 @@ Use [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html). It can be ad
The current style is defined in [.clang-format](https://gitlab.opengeosys.org/ogs/ogs/-/blob/master/.clang-format). The current style is defined in [.clang-format](https://gitlab.opengeosys.org/ogs/ogs/-/blob/master/.clang-format).
A pre-commit hook for git checking the code formatting can be found [here](https://gitlab.opengeosys.org/ogs/ogs-utils/-/tree/master/dev/code-formatting/clang-format-pre-commit-hook).
## Python ## Python
Use [`black`](https://black.readthedocs.io/en/stable/). It can be added to be automatically run on save in your editor / IDE: Use [`black`](https://black.readthedocs.io/en/stable/). It can be added to be automatically run on save in your editor / IDE:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment