File indexing completed on 2024-04-14 15:20:02

0001 #!/usr/bin/env bash
0002 
0003 # SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0004 # SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
0005 # Based on okular/hooks/pre-commit, credits go to Albert Astals Cid
0006 
0007 readonly output=$(git clang-format -v --diff)
0008 
0009 if [[ "$output" == *"no modified files to format"* ]]; then exit 0; fi
0010 if [[ "$output" == *"clang-format did not modify any files"* ]]; then exit 0; fi
0011 
0012 echo "ERROR: You have unformatted changes, please format your files. You can do this using the following commands:"
0013 echo "       git clang-format --force # format the changed parts"
0014 echo "       git clang-format --diff # preview the changes done by the formatter"
0015 exit 1