Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: format.sh issues #1946

Merged
merged 1 commit into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions circuits/cpp/barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ rm -rf ./build-wasm
# Install formatting git hook.
HOOKS_DIR=$(git rev-parse --git-path hooks)
# The pre-commit script will live in a barretenberg-specific hooks directory
# Find it based on the current working directory.
echo "cd $(pwd)/cpp && ./format.sh staged" > $HOOKS_DIR/pre-commit
# Find it based on the script directory.
# TODO(AD) it is a bit unintuitive that bootstrap sets one up for a barretenberg-oriented workflow
SCRIPT_PWD=`pwd` # fix: capture pwd instead of writing into script
echo "cd $SCRIPT_PWD && ./format.sh staged" > $HOOKS_DIR/pre-commit
chmod +x $HOOKS_DIR/pre-commit

# Determine system.
Expand Down
9 changes: 3 additions & 6 deletions circuits/cpp/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,18 @@ set -e

if [ "$1" == "staged" ]; then
echo Formatting staged files...
# we filter barretenberg, see #1149
for FILE in $(git diff-index --diff-filter=d --relative --cached --name-only HEAD | grep -e '\.\(cpp\|hpp\|tcc\)$' | grep -v barretenberg); do
for FILE in $(git diff-index --diff-filter=d --relative --cached --name-only HEAD | grep -e '\.\(cpp\|hpp\|tcc\)$'); do
clang-format -i $FILE
sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak
git add $FILE
done
elif [ -n "$1" ]; then
# we filter barretenberg, see #1149
for FILE in $(git diff-index --relative --name-only $1 | grep -e '\.\(cpp\|hpp\|tcc\)$' | grep -v barretenberg); do
for FILE in $(git diff-index --relative --name-only $1 | grep -e '\.\(cpp\|hpp\|tcc\)$'); do
clang-format -i $FILE
sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak
done
else
# we filter barretenberg, see #1149
for FILE in $(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v src/boost | grep -v barretenberg); do
for FILE in $(find ./src -iname *.hpp -o -iname *.cpp -o -iname *.tcc | grep -v src/boost); do
clang-format -i $FILE
sed -i.bak 's/\r$//' $FILE && rm ${FILE}.bak
done
Expand Down