#!/bin/bash # Owner: gchips-productivity-team@google.com # VERSION: 2019-12-16 # Pre commit hook to auto format code using git clang-format
# change the default style to Google
git config --global clangformat.style Google
# default PRE_COMMIT_CLANG_FORMAT to true
PRE_COMMIT_CLANG_FORMAT="${PRE_COMMIT_CLANG_FORMAT:-true}"
check_clang_format() { if ! [ -x "$(command -v clang-format)" ]; then echo"Warning: clang-format not found. Unable to format source code before commit. Please check go/clang-format-setup for setup instructions." fi
}
if [ "$PRE_COMMIT_CLANG_FORMAT" = true ] ; then
check_clang_format
FILES=$(git clang-format)
counter=0 for file in $FILES ; do if [[ -f "$file" ]]; then
git add ${file} echo -e "[Info] Changes in ${file} have been formatted"
((counter++)) fi done
# Run google's default pre-commit if [ -x /usr/lib/git-core/google_hook ]; then
/usr/lib/git-core/google_hook pre-commit "$@" else echo'warning: Cannot run /usr/lib/git-core/google_hook.' \ 'If this is unexpected, please file a go/git-bug' >&2 fi
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-27)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.