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: check_format(_local) for selected directories #2634

Merged
merged 2 commits into from
Nov 7, 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
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 \
andiwand marked this conversation as resolved.
Show resolved Hide resolved
--user "${USER_ID}:${GROUP_ID}" \
-w "/work_dir" \
ghcr.io/acts-project/format14:v41 \
CI/check_format .
CI/check_format $1
Loading