-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use docker so that you can clang-format using version 15 everywhere y…
…ou are. (#585) * Use docker so that you can clang-format using version 15 everywhere you are. * cleaning/simplifying * setting version to 15 * silencing command not found * changing repo
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
COMMAND=$* | ||
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | ||
MAINSOURCE=$SCRIPTPATH/.. | ||
ALL_ADA_FILES=$(cd $MAINSOURCE && git ls-tree --full-tree --name-only -r HEAD | grep -e ".*\.\(c\|h\|cc\|cpp\|hh\)\$" | grep -vFf clang-format-ignore.txt) | ||
|
||
if clang-format-15 --version 2>/dev/null | grep -qF 'version 15.'; then | ||
cd $MAINSOURCE; clang-format-15 --style=file --verbose -i "$@" $ALL_ADA_FILES | ||
exit 0 | ||
elif clang-format --version 2>/dev/null | grep -qF 'version 15.'; then | ||
cd $MAINSOURCE; clang-format --style=file --verbose -i "$@" $ALL_ADA_FILES | ||
exit 0 | ||
fi | ||
echo "Trying to use docker" | ||
command -v docker >/dev/null 2>&1 || { echo >&2 "Please install docker. E.g., go to https://www.docker.com/products/docker-desktop Type 'docker' to diagnose the problem."; exit 1; } | ||
docker info >/dev/null 2>&1 || { echo >&2 "Docker server is not running? type 'docker info'."; exit 1; } | ||
|
||
if [ -t 0 ]; then DOCKER_ARGS=-it; fi | ||
docker pull kszonek/clang-format-15 | ||
|
||
docker run --rm $DOCKER_ARGS -v "$MAINSOURCE":"$MAINSOURCE":Z -w "$MAINSOURCE" -u "$(id -u $USER):$(id -g $USER)" kszonek/clang-format-15 --style=file --verbose -i "$@" $ALL_ADA_FILES | ||
|
||
|