blob: b1668eb876a0f088efd649a8e552c64cf6c94359 [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 copied from the engine repo, which has its own formatting rules.
# 3. Not in third_party repos, which have their own formatting rules.
source_files="$(git diff --cached --name-only --diff-filter=ACM | grep -v "/engine/" | grep -v "/third_party/" | 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.