File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 22
33set -e
44
5+ # Determine the script directory and repository root
6+ SCRIPT_DIR=$( cd " $( dirname " $0 " ) " && pwd)
7+ REPO_ROOT=$( cd " $SCRIPT_DIR /.." && pwd)
8+
59# Go to the repository root directory.
6- cd " $( dirname " $0 " ) " /..
10+ cd " $REPO_ROOT "
711
812# clang-format's behavior changes between versions, even given the same
913# configuration.
@@ -41,16 +45,16 @@ if [ "$(docker image ls --quiet $image | wc -l)" -eq 0 ]; then
4145 esac
4246fi
4347
44- mount_path=/mnt/host
48+ mount_path=/mnt/repo
4549
46- # File paths passed to the dockerized clang-format need to be resolved and
47- # prefixed with the bind mount path.
50+ # File paths passed to the dockerized clang-format need to be relative to
51+ # the repository root and prefixed with the bind mount path.
4852#
4953# Non-path arguments (flags) are left alone.
5054process_arg () {
5155 case " $1 " in
5256 -* ) printf ' %s\0' " $1 " ;;
53- * ) printf ' %s/%s\0' " $mount_path " " $( realpath " $1 " ) " ;;
57+ * ) printf ' %s/%s\0' " $mount_path " " $1 " ;;
5458 esac
5559}
5660
@@ -65,7 +69,7 @@ docker_clang_format() {
6569 --volume /etc/passwd:/etc/passwd:ro \
6670 --volume /etc/group:/etc/group:ro \
6771 --user " $( id -u) :$( id -g) " \
68- --mount " type=bind,source=/ ,destination=$mount_path " \
72+ --mount " type=bind,source=$REPO_ROOT ,destination=$mount_path " \
6973 " $image " \
7074 clang-format $formatter_options
7175}
You can’t perform that action at this time.
0 commit comments