blob: 0cd6a712a6ee0b5774e65747476cab30e4657297 [file] [log] [blame]
Andrew Geissler9b0105c2018-01-10 10:58:35 -08001#!/bin/bash
2
3# This script reformats source files using the clang-format utility.
4#
5# Files are changed in-place, so make sure you don't have anything open in an
6# editor, and you may want to commit before formatting in case of awryness.
7#
8# This must be run on a clean repository to succeed
9#
10# Input parmameter must be full path to git repo to scan
11
12DIR=$1
13cd ${DIR}
14
15echo "Formatting code under $DIR/"
Andrew Geissler9b0105c2018-01-10 10:58:35 -080016
Adriana Kobylakbcee22b2018-01-10 16:58:27 -060017if [ -f "setup.cfg" ]; then
18 pycodestyle --show-source .
19 rc=$?
20 if [ ${rc} -ne 0 ]; then
21 exit ${rc}
22 fi
23fi
24
25if [ -f ".clang-format" ]; then
26 find . -regextype sed -regex ".*\.[hc]\(pp\)\?" -not -name "*mako*" -print0 |\
27 xargs -0 "clang-format-5.0" -i
28 git --no-pager diff --exit-code
29fi