blob: 9096de945e22e5ff797e862ee8b02654238d682f [file] [log] [blame]
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"/ || exit $?
echo-info "Formatting C++ code using clang-format..."
if [[ ! -f "${clang_format}" ]]
echo-warning "Failed to format C++ code because ${clang_format} does not exist."
echo-warning "You can usually fix this by running:"
echo-warning "bazel build --config=fuchsia_x64 //src/embedder"
echo-warning "If that does not work, please open a bug at "
# Format any C++ code that is:
# 1. Being modified by the commit.
# 2. Not from the engine repo, which has its own formatting rules.
source_files="$(git diff --cached --name-only --diff-filter=ACM | grep -v "/engine/" | grep -E "\.(cc|h)$")"
if [[ ! -z "$source_files" ]]
$clang_format -i $source_files
git add $source_files
# TODO(akbiggs): Add clang-tidy checks to lint C++ code.
# TODO(akbiggs): Format markdown code.
# TODO(akbiggs): Format bazel code.