Ensure ".clang-format" works with current clang-format tool (#1378)
This commit is contained in:
parent
a291bc8f91
commit
efc1963a7b
6 changed files with 52 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -72,3 +72,6 @@ Testing
|
|||
|
||||
# Autogenerated Build Prep artifacts
|
||||
util/build_prep/*/prep.sh
|
||||
|
||||
# Autogenerated Tooling
|
||||
.clang-format
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
|
||||
"${REPO_ROOT}/ci/update-clang-format"
|
||||
|
||||
RESULT=`python $REPO_ROOT/ci/git-clang-format.py --diff -f --commit HEAD~1 --extensions "h,hpp,cpp"`
|
||||
if [ "$RESULT" != "no modified files to format" ] && [ "$RESULT" != "clang-format did not modify any files" ]; then
|
||||
python $REPO_ROOT/ci/git-clang-format.py --diff -f --commit HEAD~1
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
find ${REPO_ROOT}/rai -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
|
||||
cd "${REPO_ROOT}"
|
||||
./ci/update-clang-format
|
||||
find rai -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
|
||||
|
|
39
ci/update-clang-format
Executable file
39
ci/update-clang-format
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
ci_dir="$(dirname "${BASH_SOURCE[0]}")"
|
||||
|
||||
set -e
|
||||
|
||||
cd "${ci_dir}/.."
|
||||
|
||||
retval='1'
|
||||
|
||||
rm -f .clang-format
|
||||
cp .clang-format.base .clang-format
|
||||
for try in {1..10}; do
|
||||
errors="$(clang-format -dump-config 2>&1 >/dev/null)" || :
|
||||
if [ -z "${errors}" ]; then
|
||||
retval='0'
|
||||
|
||||
break
|
||||
fi
|
||||
|
||||
errors_line="$(echo "${errors}" | awk '
|
||||
/^YAML:/{
|
||||
sub(/^YAML:/, "");
|
||||
sub(/:.*/, "");
|
||||
print;
|
||||
exit;
|
||||
}
|
||||
')"
|
||||
|
||||
if ! [ "${errors_line}" -gt -1 ] 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
|
||||
rm -f .clang-format.new
|
||||
sed "${errors_line} d" .clang-format > .clang-format.new
|
||||
mv .clang-format.new .clang-format
|
||||
done
|
||||
|
||||
exit "${retval}"
|
|
@ -28,7 +28,7 @@ function make_source () {
|
|||
fi
|
||||
# XXX:TODO: Update spec file with version information
|
||||
source_information
|
||||
rm -fr .git* .clang-format .travis.yml appveyor.yml asan_blacklist ci docker util
|
||||
rm -fr .git* .clang-format* .travis.yml appveyor.yml asan_blacklist ci docker util
|
||||
find . -type f ! -print 2>/dev/null | egrep -v '^\./(MD5SUMS|SHA256SUMS)$' | sort -u | sed s/'^\.\/'/''/ | sed 's/ /\\ /g' | xargs openssl md5 | sed 's@MD5(\(.*\))= \([0-9a-f]*\)@\2 \1@' > MD5SUMS 2>/dev/null
|
||||
find . -type f ! -print 2>/dev/null | egrep -v '^\./(SHA256SUMS)$' | sort -u | sed s/'^\.\/'/''/ | sed 's/ /\\ /g' | xargs openssl sha1 -sha256 | sed 's@SHA256(\(.*\))= \([0-9a-f]*\)@\2 \1@' > SHA256SUMS 2>/dev/null
|
||||
tarball_creation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue