diff options
author | Andreas Cord-Landwehr <cordlandwehr@kde.org> | 2021-05-27 16:37:24 +0200 |
---|---|---|
committer | Andreas Cord-Landwehr <cordlandwehr@kde.org> | 2021-05-27 16:37:24 +0200 |
commit | 07854bb9f0ac1ad5b5fad757395e04824c3fe9f3 (patch) | |
tree | 920b6c1eddf6903944d35ad916d0ca205affaea4 /kde-modules/kde-git-commit-hooks/clang-format.sh | |
parent | e94611c70863335efc00709541dd009e18c968a7 (diff) | |
download | extra-cmake-modules-07854bb9f0ac1ad5b5fad757395e04824c3fe9f3.tar.gz extra-cmake-modules-07854bb9f0ac1ad5b5fad757395e04824c3fe9f3.tar.bz2 |
Provide fallback error when no .clang-format file is present
This check fixes a probably rare case, where we land in a repository
that contains this clang-format.sh hook but where the format file went
missing. In such cases, clang-format falls back to the system defaults,
which brings undesired defaults, e.g. enforced line breaks in comments
after 90 chars, which cannot easily be reverted by a reformat.
Since clang-format's --fallback-style=none option is not available for
git clang-format, this comment reimplements the logic.
Diffstat (limited to 'kde-modules/kde-git-commit-hooks/clang-format.sh')
-rwxr-xr-x | kde-modules/kde-git-commit-hooks/clang-format.sh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kde-modules/kde-git-commit-hooks/clang-format.sh b/kde-modules/kde-git-commit-hooks/clang-format.sh index d351e3cd..42a16a1d 100755 --- a/kde-modules/kde-git-commit-hooks/clang-format.sh +++ b/kde-modules/kde-git-commit-hooks/clang-format.sh @@ -4,6 +4,11 @@ readonly output=$(git clang-format -v --diff) +if [[ ! -f .clang-format ]]; then + echo "ERROR: no .clang-format file found in repository root, abort format" + echo " run cmake for this repository to generate it" + exit 1 +fi if [[ "$output" == *"no modified files to format"* ]]; then exit 0; fi if [[ "$output" == *"clang-format did not modify any files"* ]]; then exit 0; fi |