gstreamer/scripts/gst-indent
Jordan Petridis b850a658ed pre-commit: Update the indent hook to work with our fork
We now have gst-indent-1.0 [1] which is a stripped down
fork of the version we expect. It's also using meson,
which is a bonus.

[1] https://gitlab.freedesktop.org/gstreamer/gst-indent

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6624>
2024-05-28 13:27:57 +00:00

45 lines
990 B
Bash
Executable file

#!/bin/sh
for execname in gst-indent-1.0 gnuindent gindent indent; do
version=`$execname --version 2>/dev/null`
if test "x$version" != "x"; then
INDENT=$execname
break
fi
done
if test -z $INDENT; then
echo "GStreamer git pre-commit hook:"
echo "Did not find GNU indent, please install it before continuing."
exit 1
fi
case `$INDENT --version` in
GNU*)
;;
default)
echo "Did not find GNU indent, please install it before continuing."
echo "(Found $INDENT, but it doesn't seem to be GNU indent)"
exit 1
;;
esac
# Run twice. GNU indent isn't idempotent
# when run once
for i in 1 2; do
$INDENT \
--braces-on-if-line \
--case-brace-indentation0 \
--case-indentation2 \
--braces-after-struct-decl-line \
--line-length80 \
--no-tabs \
--cuddle-else \
--dont-line-up-parentheses \
--continuation-indentation4 \
--honour-newlines \
--tab-size8 \
--indent-level2 \
--leave-preprocessor-space \
$* || exit $?
done