Skip to content

Commit

Permalink
fix: check_format(_local) for selected directories (#2634)
Browse files Browse the repository at this point in the history
now the docker-version also works with selected subdirectories.

add some RGB for extra performance.
  • Loading branch information
AJPfleger authored Nov 7, 2023
1 parent 7925974 commit ce35608
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
21 changes: 11 additions & 10 deletions CI/check_format
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

set -e # abort on error


if [ $# -ne 1 ]; then
echo "wrong number of arguments"
echo ""
echo "usage: check_format <DIR>"
echo "\033[31mERROR\033[0m"\
"wrong number of arguments"
echo "\tusage: check_format <DIR>\n"
exit 1
fi

Expand All @@ -33,17 +32,19 @@ if ! [ -z $CI ] || ! [ -z $GITHUB_ACTIONS ]; then
done
fi

echo "clang-format done"
echo "\033[32mINFO\033[0m"\
"clang-format done"

set +e
git diff --exit-code --stat
result=$?

if [ "$result" -eq "128" ]; then
echo "Format was successfully applied"
echo "Could not create summary of affected files"
echo "Are you in a submodule?"

if [ "$result" -eq "128" ] || [ "$result" -eq "129" ]; then
echo "\033[33mWARNING\033[0m"\
"Could not create summary of affected files"
echo "\tFormat was successfully applied"
echo "\tAre you in a submodule?"
echo "\tYou could try running check_format with sudo.\n"
fi

exit $result
11 changes: 5 additions & 6 deletions CI/check_format_local
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
set -e

if [ $# -ne 1 ]; then
echo "wrong number of arguments"
echo ""
echo "usage: check_format <DIR>"
echo "\033[31mERROR\033[0m"\
"wrong number of arguments"
echo "\tusage: check_format <DIR>\n"
exit 1
fi

# Setup some variables
WD="$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
USER_ID=`id -u`
GROUP_ID=`id -g`

docker run --rm -ti \
-v ${WD}:/work_dir:rw \
-v $PWD:/work_dir:rw \
--user "${USER_ID}:${GROUP_ID}" \
-w "/work_dir" \
ghcr.io/acts-project/format14:v41 \
CI/check_format .
CI/check_format $1

0 comments on commit ce35608

Please sign in to comment.