diff --git a/circuits/cpp/barretenberg/cpp/bootstrap.sh b/circuits/cpp/barretenberg/cpp/bootstrap.sh index e9f41cba246c..869bbc9c885c 100755 --- a/circuits/cpp/barretenberg/cpp/bootstrap.sh +++ b/circuits/cpp/barretenberg/cpp/bootstrap.sh @@ -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. diff --git a/circuits/cpp/format.sh b/circuits/cpp/format.sh index e9b2c261214a..20c99bf89938 100755 --- a/circuits/cpp/format.sh +++ b/circuits/cpp/format.sh @@ -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